<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>25.4. turtle — Turtle graphics for Tk &mdash; Python v2.6.2 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.6.2',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python v2.6.2 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="top" title="Python v2.6.2 documentation" href="../index.html" />
    <link rel="up" title="25. Graphical User Interfaces with Tk" href="tk.html" />
    <link rel="next" title="25.5. IDLE" href="idle.html" />
    <link rel="prev" title="25.3. ScrolledText — Scrolled Text Widget" href="scrolledtext.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
 

  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="idle.html" title="25.5. IDLE"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="scrolledtext.html" title="25.3. ScrolledText — Scrolled Text Widget"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v2.6.2 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="tk.html" accesskey="U">25. Graphical User Interfaces with Tk</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-turtle">
<h1>25.4. <tt class="xref docutils literal"><span class="pre">turtle</span></tt> &#8212; Turtle graphics for Tk<a class="headerlink" href="#module-turtle" title="Permalink to this headline">¶</a></h1>
<div class="section" id="introduction">
<h2>25.4.1. Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>Turtle graphics is a popular way for introducing programming to kids.  It was
part of the original Logo programming language developed by Wally Feurzig and
Seymour Papert in 1966.</p>
<p>Imagine a robotic turtle starting at (0, 0) in the x-y plane.  Give it the
command <tt class="docutils literal"><span class="pre">turtle.forward(15)</span></tt>, and it moves (on-screen!) 15 pixels in the
direction it is facing, drawing a line as it moves.  Give it the command
<tt class="docutils literal"><span class="pre">turtle.left(25)</span></tt>, and it rotates in-place 25 degrees clockwise.</p>
<p>By combining together these and similar commands, intricate shapes and pictures
can easily be drawn.</p>
<p>The <tt class="xref docutils literal"><span class="pre">turtle</span></tt> module is an extended reimplementation of the same-named
module from the Python standard distribution up to version Python 2.5.</p>
<p>It tries to keep the merits of the old turtle module and to be (nearly) 100%
compatible with it.  This means in the first place to enable the learning
programmer to use all the commands, classes and methods interactively when using
the module from within IDLE run with the <tt class="docutils literal"><span class="pre">-n</span></tt> switch.</p>
<p>The turtle module provides turtle graphics primitives, in both object-oriented
and procedure-oriented ways.  Because it uses <a title="Interface to Tcl/Tk for graphical user interfaces" class="reference external" href="tkinter.html#module-Tkinter"><tt class="xref docutils literal"><span class="pre">Tkinter</span></tt></a> for the underlying
graphics, it needs a version of python installed with Tk support.</p>
<p>The object-oriented interface uses essentially two+two classes:</p>
<ol class="arabic">
<li><p class="first">The <a title="turtle.TurtleScreen" class="reference internal" href="#turtle.TurtleScreen"><tt class="xref docutils literal"><span class="pre">TurtleScreen</span></tt></a> class defines graphics windows as a playground for
the drawing turtles.  Its constructor needs a <tt class="xref docutils literal"><span class="pre">Tkinter.Canvas</span></tt> or a
<tt class="xref docutils literal"><span class="pre">ScrolledCanvas</span></tt> as argument.  It should be used when <tt class="xref docutils literal"><span class="pre">turtle</span></tt> is
used as part of some application.</p>
<p>The function <a title="turtle.Screen" class="reference internal" href="#turtle.Screen"><tt class="xref docutils literal"><span class="pre">Screen()</span></tt></a> returns a singleton object of a
<a title="turtle.TurtleScreen" class="reference internal" href="#turtle.TurtleScreen"><tt class="xref docutils literal"><span class="pre">TurtleScreen</span></tt></a> subclass. This function should be used when
<tt class="xref docutils literal"><span class="pre">turtle</span></tt> is used as a standalone tool for doing graphics.
As a singleton object, inheriting from its class is not possible.</p>
<p>All methods of TurtleScreen/Screen also exist as functions, i.e. as part of
the procedure-oriented interface.</p>
</li>
<li><p class="first"><a title="turtle.RawTurtle" class="reference internal" href="#turtle.RawTurtle"><tt class="xref docutils literal"><span class="pre">RawTurtle</span></tt></a> (alias: <a title="turtle.RawPen" class="reference internal" href="#turtle.RawPen"><tt class="xref docutils literal"><span class="pre">RawPen</span></tt></a>) defines Turtle objects which draw
on a <a title="turtle.TurtleScreen" class="reference internal" href="#turtle.TurtleScreen"><tt class="xref docutils literal"><span class="pre">TurtleScreen</span></tt></a>.  Its constructor needs a Canvas, ScrolledCanvas
or TurtleScreen as argument, so the RawTurtle objects know where to draw.</p>
<p>Derived from RawTurtle is the subclass <a title="turtle.Turtle" class="reference internal" href="#turtle.Turtle"><tt class="xref docutils literal"><span class="pre">Turtle</span></tt></a> (alias: <tt class="xref docutils literal"><span class="pre">Pen</span></tt>),
which draws on &#8220;the&#8221; <a title="turtle.Screen" class="reference internal" href="#turtle.Screen"><tt class="xref docutils literal"><span class="pre">Screen</span></tt></a> - instance which is automatically
created, if not already present.</p>
<p>All methods of RawTurtle/Turtle also exist as functions, i.e. part of the
procedure-oriented interface.</p>
</li>
</ol>
<p>The procedural interface provides functions which are derived from the methods
of the classes <a title="turtle.Screen" class="reference internal" href="#turtle.Screen"><tt class="xref docutils literal"><span class="pre">Screen</span></tt></a> and <a title="turtle.Turtle" class="reference internal" href="#turtle.Turtle"><tt class="xref docutils literal"><span class="pre">Turtle</span></tt></a>.  They have the same names as
the corresponding methods.  A screen object is automatically created whenever a
function derived from a Screen method is called.  An (unnamed) turtle object is
automatically created whenever any of the functions derived from a Turtle method
is called.</p>
<p>To use multiple turtles an a screen one has to use the object-oriented interface.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">In the following documentation the argument list for functions is given.
Methods, of course, have the additional first argument <em>self</em> which is
omitted here.</p>
</div>
</div>
<div class="section" id="overview-over-available-turtle-and-screen-methods">
<h2>25.4.2. Overview over available Turtle and Screen methods<a class="headerlink" href="#overview-over-available-turtle-and-screen-methods" title="Permalink to this headline">¶</a></h2>
<div class="section" id="turtle-methods">
<h3>25.4.2.1. Turtle methods<a class="headerlink" href="#turtle-methods" title="Permalink to this headline">¶</a></h3>
<dl class="docutils">
<dt>Turtle motion</dt>
<dd><dl class="first last docutils">
<dt>Move and draw</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.forward" class="reference internal" href="#turtle.forward"><tt class="xref docutils literal"><span class="pre">forward()</span></tt></a> | <a title="turtle.fd" class="reference internal" href="#turtle.fd"><tt class="xref docutils literal"><span class="pre">fd()</span></tt></a></div>
<div class="line"><a title="turtle.backward" class="reference internal" href="#turtle.backward"><tt class="xref docutils literal"><span class="pre">backward()</span></tt></a> | <a title="turtle.bk" class="reference internal" href="#turtle.bk"><tt class="xref docutils literal"><span class="pre">bk()</span></tt></a> | <a title="turtle.back" class="reference internal" href="#turtle.back"><tt class="xref docutils literal"><span class="pre">back()</span></tt></a></div>
<div class="line"><a title="turtle.right" class="reference internal" href="#turtle.right"><tt class="xref docutils literal"><span class="pre">right()</span></tt></a> | <a title="turtle.rt" class="reference internal" href="#turtle.rt"><tt class="xref docutils literal"><span class="pre">rt()</span></tt></a></div>
<div class="line"><a title="turtle.left" class="reference internal" href="#turtle.left"><tt class="xref docutils literal"><span class="pre">left()</span></tt></a> | <a title="turtle.lt" class="reference internal" href="#turtle.lt"><tt class="xref docutils literal"><span class="pre">lt()</span></tt></a></div>
<div class="line"><a title="turtle.goto" class="reference internal" href="#turtle.goto"><tt class="xref docutils literal"><span class="pre">goto()</span></tt></a> | <a title="turtle.setpos" class="reference internal" href="#turtle.setpos"><tt class="xref docutils literal"><span class="pre">setpos()</span></tt></a> | <a title="turtle.setposition" class="reference internal" href="#turtle.setposition"><tt class="xref docutils literal"><span class="pre">setposition()</span></tt></a></div>
<div class="line"><a title="turtle.setx" class="reference internal" href="#turtle.setx"><tt class="xref docutils literal"><span class="pre">setx()</span></tt></a></div>
<div class="line"><a title="turtle.sety" class="reference internal" href="#turtle.sety"><tt class="xref docutils literal"><span class="pre">sety()</span></tt></a></div>
<div class="line"><a title="turtle.setheading" class="reference internal" href="#turtle.setheading"><tt class="xref docutils literal"><span class="pre">setheading()</span></tt></a> | <a title="turtle.seth" class="reference internal" href="#turtle.seth"><tt class="xref docutils literal"><span class="pre">seth()</span></tt></a></div>
<div class="line"><a title="turtle.home" class="reference internal" href="#turtle.home"><tt class="xref docutils literal"><span class="pre">home()</span></tt></a></div>
<div class="line"><a title="turtle.circle" class="reference internal" href="#turtle.circle"><tt class="xref docutils literal"><span class="pre">circle()</span></tt></a></div>
<div class="line"><a title="turtle.dot" class="reference internal" href="#turtle.dot"><tt class="xref docutils literal"><span class="pre">dot()</span></tt></a></div>
<div class="line"><a title="turtle.stamp" class="reference internal" href="#turtle.stamp"><tt class="xref docutils literal"><span class="pre">stamp()</span></tt></a></div>
<div class="line"><a title="turtle.clearstamp" class="reference internal" href="#turtle.clearstamp"><tt class="xref docutils literal"><span class="pre">clearstamp()</span></tt></a></div>
<div class="line"><a title="turtle.clearstamps" class="reference internal" href="#turtle.clearstamps"><tt class="xref docutils literal"><span class="pre">clearstamps()</span></tt></a></div>
<div class="line"><a title="turtle.undo" class="reference internal" href="#turtle.undo"><tt class="xref docutils literal"><span class="pre">undo()</span></tt></a></div>
<div class="line"><a title="turtle.speed" class="reference internal" href="#turtle.speed"><tt class="xref docutils literal"><span class="pre">speed()</span></tt></a></div>
</div>
</dd>
<dt>Tell Turtle&#8217;s state</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.position" class="reference internal" href="#turtle.position"><tt class="xref docutils literal"><span class="pre">position()</span></tt></a> | <a title="turtle.pos" class="reference internal" href="#turtle.pos"><tt class="xref docutils literal"><span class="pre">pos()</span></tt></a></div>
<div class="line"><a title="turtle.towards" class="reference internal" href="#turtle.towards"><tt class="xref docutils literal"><span class="pre">towards()</span></tt></a></div>
<div class="line"><a title="turtle.xcor" class="reference internal" href="#turtle.xcor"><tt class="xref docutils literal"><span class="pre">xcor()</span></tt></a></div>
<div class="line"><a title="turtle.ycor" class="reference internal" href="#turtle.ycor"><tt class="xref docutils literal"><span class="pre">ycor()</span></tt></a></div>
<div class="line"><a title="turtle.heading" class="reference internal" href="#turtle.heading"><tt class="xref docutils literal"><span class="pre">heading()</span></tt></a></div>
<div class="line"><a title="turtle.distance" class="reference internal" href="#turtle.distance"><tt class="xref docutils literal"><span class="pre">distance()</span></tt></a></div>
</div>
</dd>
<dt>Setting and measurement</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.degrees" class="reference internal" href="#turtle.degrees"><tt class="xref docutils literal"><span class="pre">degrees()</span></tt></a></div>
<div class="line"><a title="turtle.radians" class="reference internal" href="#turtle.radians"><tt class="xref docutils literal"><span class="pre">radians()</span></tt></a></div>
</div>
</dd>
</dl>
</dd>
<dt>Pen control</dt>
<dd><dl class="first last docutils">
<dt>Drawing state</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.pendown" class="reference internal" href="#turtle.pendown"><tt class="xref docutils literal"><span class="pre">pendown()</span></tt></a> | <a title="turtle.pd" class="reference internal" href="#turtle.pd"><tt class="xref docutils literal"><span class="pre">pd()</span></tt></a> | <a title="turtle.down" class="reference internal" href="#turtle.down"><tt class="xref docutils literal"><span class="pre">down()</span></tt></a></div>
<div class="line"><a title="turtle.penup" class="reference internal" href="#turtle.penup"><tt class="xref docutils literal"><span class="pre">penup()</span></tt></a> | <a title="turtle.pu" class="reference internal" href="#turtle.pu"><tt class="xref docutils literal"><span class="pre">pu()</span></tt></a> | <a title="turtle.up" class="reference internal" href="#turtle.up"><tt class="xref docutils literal"><span class="pre">up()</span></tt></a></div>
<div class="line"><a title="turtle.pensize" class="reference internal" href="#turtle.pensize"><tt class="xref docutils literal"><span class="pre">pensize()</span></tt></a> | <a title="turtle.width" class="reference internal" href="#turtle.width"><tt class="xref docutils literal"><span class="pre">width()</span></tt></a></div>
<div class="line"><a title="turtle.pen" class="reference internal" href="#turtle.pen"><tt class="xref docutils literal"><span class="pre">pen()</span></tt></a></div>
<div class="line"><a title="turtle.isdown" class="reference internal" href="#turtle.isdown"><tt class="xref docutils literal"><span class="pre">isdown()</span></tt></a></div>
</div>
</dd>
<dt>Color control</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.color" class="reference internal" href="#turtle.color"><tt class="xref docutils literal"><span class="pre">color()</span></tt></a></div>
<div class="line"><a title="turtle.pencolor" class="reference internal" href="#turtle.pencolor"><tt class="xref docutils literal"><span class="pre">pencolor()</span></tt></a></div>
<div class="line"><a title="turtle.fillcolor" class="reference internal" href="#turtle.fillcolor"><tt class="xref docutils literal"><span class="pre">fillcolor()</span></tt></a></div>
</div>
</dd>
<dt>Filling</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.fill" class="reference internal" href="#turtle.fill"><tt class="xref docutils literal"><span class="pre">fill()</span></tt></a></div>
<div class="line"><a title="turtle.begin_fill" class="reference internal" href="#turtle.begin_fill"><tt class="xref docutils literal"><span class="pre">begin_fill()</span></tt></a></div>
<div class="line"><a title="turtle.end_fill" class="reference internal" href="#turtle.end_fill"><tt class="xref docutils literal"><span class="pre">end_fill()</span></tt></a></div>
</div>
</dd>
<dt>More drawing control</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.reset" class="reference internal" href="#turtle.reset"><tt class="xref docutils literal"><span class="pre">reset()</span></tt></a></div>
<div class="line"><a title="turtle.clear" class="reference internal" href="#turtle.clear"><tt class="xref docutils literal"><span class="pre">clear()</span></tt></a></div>
<div class="line"><a title="turtle.write" class="reference internal" href="#turtle.write"><tt class="xref docutils literal"><span class="pre">write()</span></tt></a></div>
</div>
</dd>
</dl>
</dd>
<dt>Turtle state</dt>
<dd><dl class="first last docutils">
<dt>Visibility</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.showturtle" class="reference internal" href="#turtle.showturtle"><tt class="xref docutils literal"><span class="pre">showturtle()</span></tt></a> | <a title="turtle.st" class="reference internal" href="#turtle.st"><tt class="xref docutils literal"><span class="pre">st()</span></tt></a></div>
<div class="line"><a title="turtle.hideturtle" class="reference internal" href="#turtle.hideturtle"><tt class="xref docutils literal"><span class="pre">hideturtle()</span></tt></a> | <a title="turtle.ht" class="reference internal" href="#turtle.ht"><tt class="xref docutils literal"><span class="pre">ht()</span></tt></a></div>
<div class="line"><a title="turtle.isvisible" class="reference internal" href="#turtle.isvisible"><tt class="xref docutils literal"><span class="pre">isvisible()</span></tt></a></div>
</div>
</dd>
<dt>Appearance</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.shape" class="reference internal" href="#turtle.shape"><tt class="xref docutils literal"><span class="pre">shape()</span></tt></a></div>
<div class="line"><a title="turtle.resizemode" class="reference internal" href="#turtle.resizemode"><tt class="xref docutils literal"><span class="pre">resizemode()</span></tt></a></div>
<div class="line"><a title="turtle.shapesize" class="reference internal" href="#turtle.shapesize"><tt class="xref docutils literal"><span class="pre">shapesize()</span></tt></a> | <tt class="xref docutils literal"><span class="pre">turtlesize()</span></tt></div>
<div class="line"><a title="turtle.settiltangle" class="reference internal" href="#turtle.settiltangle"><tt class="xref docutils literal"><span class="pre">settiltangle()</span></tt></a></div>
<div class="line"><a title="turtle.tiltangle" class="reference internal" href="#turtle.tiltangle"><tt class="xref docutils literal"><span class="pre">tiltangle()</span></tt></a></div>
<div class="line"><a title="turtle.tilt" class="reference internal" href="#turtle.tilt"><tt class="xref docutils literal"><span class="pre">tilt()</span></tt></a></div>
</div>
</dd>
</dl>
</dd>
<dt>Using events</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.onclick" class="reference internal" href="#turtle.onclick"><tt class="xref docutils literal"><span class="pre">onclick()</span></tt></a></div>
<div class="line"><a title="turtle.onrelease" class="reference internal" href="#turtle.onrelease"><tt class="xref docutils literal"><span class="pre">onrelease()</span></tt></a></div>
<div class="line"><a title="turtle.ondrag" class="reference internal" href="#turtle.ondrag"><tt class="xref docutils literal"><span class="pre">ondrag()</span></tt></a></div>
</div>
</dd>
<dt>Special Turtle methods</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.begin_poly" class="reference internal" href="#turtle.begin_poly"><tt class="xref docutils literal"><span class="pre">begin_poly()</span></tt></a></div>
<div class="line"><a title="turtle.end_poly" class="reference internal" href="#turtle.end_poly"><tt class="xref docutils literal"><span class="pre">end_poly()</span></tt></a></div>
<div class="line"><a title="turtle.get_poly" class="reference internal" href="#turtle.get_poly"><tt class="xref docutils literal"><span class="pre">get_poly()</span></tt></a></div>
<div class="line"><a title="turtle.clone" class="reference internal" href="#turtle.clone"><tt class="xref docutils literal"><span class="pre">clone()</span></tt></a></div>
<div class="line"><a title="turtle.getturtle" class="reference internal" href="#turtle.getturtle"><tt class="xref docutils literal"><span class="pre">getturtle()</span></tt></a> | <tt class="xref docutils literal"><span class="pre">getpen()</span></tt></div>
<div class="line"><a title="turtle.getscreen" class="reference internal" href="#turtle.getscreen"><tt class="xref docutils literal"><span class="pre">getscreen()</span></tt></a></div>
<div class="line"><a title="turtle.setundobuffer" class="reference internal" href="#turtle.setundobuffer"><tt class="xref docutils literal"><span class="pre">setundobuffer()</span></tt></a></div>
<div class="line"><a title="turtle.undobufferentries" class="reference internal" href="#turtle.undobufferentries"><tt class="xref docutils literal"><span class="pre">undobufferentries()</span></tt></a></div>
<div class="line"><a title="turtle.tracer" class="reference internal" href="#turtle.tracer"><tt class="xref docutils literal"><span class="pre">tracer()</span></tt></a></div>
<div class="line"><a title="turtle.window_width" class="reference internal" href="#turtle.window_width"><tt class="xref docutils literal"><span class="pre">window_width()</span></tt></a></div>
<div class="line"><a title="turtle.window_height" class="reference internal" href="#turtle.window_height"><tt class="xref docutils literal"><span class="pre">window_height()</span></tt></a></div>
</div>
</dd>
</dl>
</div>
<div class="section" id="methods-of-turtlescreen-screen">
<h3>25.4.2.2. Methods of TurtleScreen/Screen<a class="headerlink" href="#methods-of-turtlescreen-screen" title="Permalink to this headline">¶</a></h3>
<dl class="docutils">
<dt>Window control</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.bgcolor" class="reference internal" href="#turtle.bgcolor"><tt class="xref docutils literal"><span class="pre">bgcolor()</span></tt></a></div>
<div class="line"><a title="turtle.bgpic" class="reference internal" href="#turtle.bgpic"><tt class="xref docutils literal"><span class="pre">bgpic()</span></tt></a></div>
<div class="line"><a title="turtle.clear" class="reference internal" href="#turtle.clear"><tt class="xref docutils literal"><span class="pre">clear()</span></tt></a> | <a title="turtle.clearscreen" class="reference internal" href="#turtle.clearscreen"><tt class="xref docutils literal"><span class="pre">clearscreen()</span></tt></a></div>
<div class="line"><a title="turtle.reset" class="reference internal" href="#turtle.reset"><tt class="xref docutils literal"><span class="pre">reset()</span></tt></a> | <a title="turtle.resetscreen" class="reference internal" href="#turtle.resetscreen"><tt class="xref docutils literal"><span class="pre">resetscreen()</span></tt></a></div>
<div class="line"><a title="turtle.screensize" class="reference internal" href="#turtle.screensize"><tt class="xref docutils literal"><span class="pre">screensize()</span></tt></a></div>
<div class="line"><a title="turtle.setworldcoordinates" class="reference internal" href="#turtle.setworldcoordinates"><tt class="xref docutils literal"><span class="pre">setworldcoordinates()</span></tt></a></div>
</div>
</dd>
<dt>Animation control</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.delay" class="reference internal" href="#turtle.delay"><tt class="xref docutils literal"><span class="pre">delay()</span></tt></a></div>
<div class="line"><a title="turtle.tracer" class="reference internal" href="#turtle.tracer"><tt class="xref docutils literal"><span class="pre">tracer()</span></tt></a></div>
<div class="line"><a title="turtle.update" class="reference internal" href="#turtle.update"><tt class="xref docutils literal"><span class="pre">update()</span></tt></a></div>
</div>
</dd>
<dt>Using screen events</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.listen" class="reference internal" href="#turtle.listen"><tt class="xref docutils literal"><span class="pre">listen()</span></tt></a></div>
<div class="line"><a title="turtle.onkey" class="reference internal" href="#turtle.onkey"><tt class="xref docutils literal"><span class="pre">onkey()</span></tt></a></div>
<div class="line"><a title="turtle.onclick" class="reference internal" href="#turtle.onclick"><tt class="xref docutils literal"><span class="pre">onclick()</span></tt></a> | <a title="turtle.onscreenclick" class="reference internal" href="#turtle.onscreenclick"><tt class="xref docutils literal"><span class="pre">onscreenclick()</span></tt></a></div>
<div class="line"><a title="turtle.ontimer" class="reference internal" href="#turtle.ontimer"><tt class="xref docutils literal"><span class="pre">ontimer()</span></tt></a></div>
</div>
</dd>
<dt>Settings and special methods</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.mode" class="reference internal" href="#turtle.mode"><tt class="xref docutils literal"><span class="pre">mode()</span></tt></a></div>
<div class="line"><a title="turtle.colormode" class="reference internal" href="#turtle.colormode"><tt class="xref docutils literal"><span class="pre">colormode()</span></tt></a></div>
<div class="line"><a title="turtle.getcanvas" class="reference internal" href="#turtle.getcanvas"><tt class="xref docutils literal"><span class="pre">getcanvas()</span></tt></a></div>
<div class="line"><a title="turtle.getshapes" class="reference internal" href="#turtle.getshapes"><tt class="xref docutils literal"><span class="pre">getshapes()</span></tt></a></div>
<div class="line"><a title="turtle.register_shape" class="reference internal" href="#turtle.register_shape"><tt class="xref docutils literal"><span class="pre">register_shape()</span></tt></a> | <a title="turtle.addshape" class="reference internal" href="#turtle.addshape"><tt class="xref docutils literal"><span class="pre">addshape()</span></tt></a></div>
<div class="line"><a title="turtle.turtles" class="reference internal" href="#turtle.turtles"><tt class="xref docutils literal"><span class="pre">turtles()</span></tt></a></div>
<div class="line"><a title="turtle.window_height" class="reference internal" href="#turtle.window_height"><tt class="xref docutils literal"><span class="pre">window_height()</span></tt></a></div>
<div class="line"><a title="turtle.window_width" class="reference internal" href="#turtle.window_width"><tt class="xref docutils literal"><span class="pre">window_width()</span></tt></a></div>
</div>
</dd>
<dt>Methods specific to Screen</dt>
<dd><div class="first last line-block">
<div class="line"><a title="turtle.bye" class="reference internal" href="#turtle.bye"><tt class="xref docutils literal"><span class="pre">bye()</span></tt></a></div>
<div class="line"><a title="turtle.exitonclick" class="reference internal" href="#turtle.exitonclick"><tt class="xref docutils literal"><span class="pre">exitonclick()</span></tt></a></div>
<div class="line"><a title="turtle.setup" class="reference internal" href="#turtle.setup"><tt class="xref docutils literal"><span class="pre">setup()</span></tt></a></div>
<div class="line"><a title="turtle.title" class="reference internal" href="#turtle.title"><tt class="xref docutils literal"><span class="pre">title()</span></tt></a></div>
</div>
</dd>
</dl>
</div>
</div>
<div class="section" id="methods-of-rawturtle-turtle-and-corresponding-functions">
<h2>25.4.3. Methods of RawTurtle/Turtle and corresponding functions<a class="headerlink" href="#methods-of-rawturtle-turtle-and-corresponding-functions" title="Permalink to this headline">¶</a></h2>
<p>Most of the examples in this section refer to a Turtle instance called
<tt class="docutils literal"><span class="pre">turtle</span></tt>.</p>
<div class="section" id="turtle-motion">
<h3>25.4.3.1. Turtle motion<a class="headerlink" href="#turtle-motion" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.forward">
<tt class="descclassname">turtle.</tt><tt class="descname">forward</tt><big>(</big><em>distance</em><big>)</big><a class="headerlink" href="#turtle.forward" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.fd">
<tt class="descclassname">turtle.</tt><tt class="descname">fd</tt><big>(</big><em>distance</em><big>)</big><a class="headerlink" href="#turtle.fd" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>distance</em> &#8211; a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Move the turtle forward by the specified <em>distance</em>, in the direction the
turtle is headed.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00, 0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mf">25</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(25.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="o">-</span><span class="mf">75</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(-50.00,0.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.back">
<tt class="descclassname">turtle.</tt><tt class="descname">back</tt><big>(</big><em>distance</em><big>)</big><a class="headerlink" href="#turtle.back" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.bk">
<tt class="descclassname">turtle.</tt><tt class="descname">bk</tt><big>(</big><em>distance</em><big>)</big><a class="headerlink" href="#turtle.bk" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.backward">
<tt class="descclassname">turtle.</tt><tt class="descname">backward</tt><big>(</big><em>distance</em><big>)</big><a class="headerlink" href="#turtle.backward" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>distance</em> &#8211; a number</td>
</tr>
</tbody>
</table>
<p>Move the turtle backward by <em>distance</em>, opposite to the direction the
turtle is headed.  Do not change the turtle&#8217;s heading.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00, 0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">backward</span><span class="p">(</span><span class="mf">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(-30.00, 0.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.right">
<tt class="descclassname">turtle.</tt><tt class="descname">right</tt><big>(</big><em>angle</em><big>)</big><a class="headerlink" href="#turtle.right" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.rt">
<tt class="descclassname">turtle.</tt><tt class="descname">rt</tt><big>(</big><em>angle</em><big>)</big><a class="headerlink" href="#turtle.rt" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>angle</em> &#8211; a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Turn turtle right by <em>angle</em> units.  (Units are by default degrees, but
can be set via the <a title="turtle.degrees" class="reference internal" href="#turtle.degrees"><tt class="xref docutils literal"><span class="pre">degrees()</span></tt></a> and <a title="turtle.radians" class="reference internal" href="#turtle.radians"><tt class="xref docutils literal"><span class="pre">radians()</span></tt></a> functions.)  Angle
orientation depends on the turtle mode, see <a title="turtle.mode" class="reference internal" href="#turtle.mode"><tt class="xref docutils literal"><span class="pre">mode()</span></tt></a>.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">22.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">right</span><span class="p">(</span><span class="mf">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">337.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.left">
<tt class="descclassname">turtle.</tt><tt class="descname">left</tt><big>(</big><em>angle</em><big>)</big><a class="headerlink" href="#turtle.left" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.lt">
<tt class="descclassname">turtle.</tt><tt class="descname">lt</tt><big>(</big><em>angle</em><big>)</big><a class="headerlink" href="#turtle.lt" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>angle</em> &#8211; a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Turn turtle left by <em>angle</em> units.  (Units are by default degrees, but
can be set via the <a title="turtle.degrees" class="reference internal" href="#turtle.degrees"><tt class="xref docutils literal"><span class="pre">degrees()</span></tt></a> and <a title="turtle.radians" class="reference internal" href="#turtle.radians"><tt class="xref docutils literal"><span class="pre">radians()</span></tt></a> functions.)  Angle
orientation depends on the turtle mode, see <a title="turtle.mode" class="reference internal" href="#turtle.mode"><tt class="xref docutils literal"><span class="pre">mode()</span></tt></a>.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">22.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mf">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">67.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.goto">
<tt class="descclassname">turtle.</tt><tt class="descname">goto</tt><big>(</big><em>x</em>, <em>y=None</em><big>)</big><a class="headerlink" href="#turtle.goto" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.setpos">
<tt class="descclassname">turtle.</tt><tt class="descname">setpos</tt><big>(</big><em>x</em>, <em>y=None</em><big>)</big><a class="headerlink" href="#turtle.setpos" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.setposition">
<tt class="descclassname">turtle.</tt><tt class="descname">setposition</tt><big>(</big><em>x</em>, <em>y=None</em><big>)</big><a class="headerlink" href="#turtle.setposition" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>x</em> &#8211; a number or a pair/vector of numbers</li>
<li><em>y</em> &#8211; a number or <tt class="xref docutils literal"><span class="pre">None</span></tt></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>If <em>y</em> is <tt class="xref docutils literal"><span class="pre">None</span></tt>, <em>x</em> must be a pair of coordinates or a <a title="turtle.Vec2D" class="reference internal" href="#turtle.Vec2D"><tt class="xref docutils literal"><span class="pre">Vec2D</span></tt></a>
(e.g. as returned by <a title="turtle.pos" class="reference internal" href="#turtle.pos"><tt class="xref docutils literal"><span class="pre">pos()</span></tt></a>).</p>
<p>Move turtle to an absolute position.  If the pen is down, draw line.  Do
not change the turtle&#8217;s orientation.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">tp</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">tp</span>
<span class="go">(0.00, 0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setpos</span><span class="p">(</span><span class="mf">60</span><span class="p">,</span><span class="mf">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(60.00,30.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setpos</span><span class="p">((</span><span class="mf">20</span><span class="p">,</span><span class="mf">80</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(20.00,80.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setpos</span><span class="p">(</span><span class="n">tp</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.setx">
<tt class="descclassname">turtle.</tt><tt class="descname">setx</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#turtle.setx" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>x</em> &#8211; a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Set the turtle&#8217;s first coordinate to <em>x</em>, leave second coordinate
unchanged.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00, 240.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setx</span><span class="p">(</span><span class="mf">10</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(10.00, 240.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.sety">
<tt class="descclassname">turtle.</tt><tt class="descname">sety</tt><big>(</big><em>y</em><big>)</big><a class="headerlink" href="#turtle.sety" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>y</em> &#8211; a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Set the turtle&#8217;s second coordinate to <em>y</em>, leave first coordinate unchanged.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00, 40.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">sety</span><span class="p">(</span><span class="o">-</span><span class="mf">10</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00, -10.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.setheading">
<tt class="descclassname">turtle.</tt><tt class="descname">setheading</tt><big>(</big><em>to_angle</em><big>)</big><a class="headerlink" href="#turtle.setheading" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.seth">
<tt class="descclassname">turtle.</tt><tt class="descname">seth</tt><big>(</big><em>to_angle</em><big>)</big><a class="headerlink" href="#turtle.seth" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>to_angle</em> &#8211; a number (integer or float)</td>
</tr>
</tbody>
</table>
<p>Set the orientation of the turtle to <em>to_angle</em>.  Here are some common
directions in degrees:</p>
<table border="1" class="docutils">
<colgroup>
<col width="49%" />
<col width="51%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">standard mode</th>
<th class="head">logo mode</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>0 - east</td>
<td>0 - north</td>
</tr>
<tr><td>90 - north</td>
<td>90 - east</td>
</tr>
<tr><td>180 - west</td>
<td>180 - south</td>
</tr>
<tr><td>270 - south</td>
<td>270 - west</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setheading</span><span class="p">(</span><span class="mf">90</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">90</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.home">
<tt class="descclassname">turtle.</tt><tt class="descname">home</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.home" title="Permalink to this definition">¶</a></dt>
<dd>Move turtle to the origin &#8211; coordinates (0,0) &#8211; and set its heading to
its start-orientation (which depends on the mode, see <a title="turtle.mode" class="reference internal" href="#turtle.mode"><tt class="xref docutils literal"><span class="pre">mode()</span></tt></a>).</dd></dl>

<dl class="function">
<dt id="turtle.circle">
<tt class="descclassname">turtle.</tt><tt class="descname">circle</tt><big>(</big><em>radius</em>, <em>extent=None</em>, <em>steps=None</em><big>)</big><a class="headerlink" href="#turtle.circle" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>radius</em> &#8211; a number</li>
<li><em>extent</em> &#8211; a number (or <tt class="xref docutils literal"><span class="pre">None</span></tt>)</li>
<li><em>steps</em> &#8211; an integer (or <tt class="xref docutils literal"><span class="pre">None</span></tt>)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Draw a circle with given <em>radius</em>.  The center is <em>radius</em> units left of
the turtle; <em>extent</em> &#8211; an angle &#8211; determines which part of the circle
is drawn.  If <em>extent</em> is not given, draw the entire circle.  If <em>extent</em>
is not a full circle, one endpoint of the arc is the current pen
position.  Draw the arc in counterclockwise direction if <em>radius</em> is
positive, otherwise in clockwise direction.  Finally the direction of the
turtle is changed by the amount of <em>extent</em>.</p>
<p>As the circle is approximated by an inscribed regular polygon, <em>steps</em>
determines the number of steps to use.  If not given, it will be
calculated automatically.  May be used to draw regular polygons.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">circle</span><span class="p">(</span><span class="mf">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">circle</span><span class="p">(</span><span class="mf">120</span><span class="p">,</span> <span class="mf">180</span><span class="p">)</span>  <span class="c"># draw a semicircle</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.dot">
<tt class="descclassname">turtle.</tt><tt class="descname">dot</tt><big>(</big><em>size=None</em>, <em>*color</em><big>)</big><a class="headerlink" href="#turtle.dot" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>size</em> &#8211; an integer &gt;= 1 (if given)</li>
<li><em>color</em> &#8211; a colorstring or a numeric color tuple</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Draw a circular dot with diameter <em>size</em>, using <em>color</em>.  If <em>size</em> is
not given, the maximum of pensize+4 and 2*pensize is used.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">dot</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mf">50</span><span class="p">);</span> <span class="n">turtle</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="mf">20</span><span class="p">,</span> <span class="s">&quot;blue&quot;</span><span class="p">);</span> <span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mf">50</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.stamp">
<tt class="descclassname">turtle.</tt><tt class="descname">stamp</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.stamp" title="Permalink to this definition">¶</a></dt>
<dd><p>Stamp a copy of the turtle shape onto the canvas at the current turtle
position.  Return a stamp_id for that stamp, which can be used to delete
it by calling <tt class="docutils literal"><span class="pre">clearstamp(stamp_id)</span></tt>.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s">&quot;blue&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">stamp</span><span class="p">()</span>
<span class="go">13</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mf">50</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.clearstamp">
<tt class="descclassname">turtle.</tt><tt class="descname">clearstamp</tt><big>(</big><em>stampid</em><big>)</big><a class="headerlink" href="#turtle.clearstamp" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>stampid</em> &#8211; an integer, must be return value of previous
<a title="turtle.stamp" class="reference internal" href="#turtle.stamp"><tt class="xref docutils literal"><span class="pre">stamp()</span></tt></a> call</td>
</tr>
</tbody>
</table>
<p>Delete stamp with given <em>stampid</em>.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s">&quot;blue&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">astamp</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">stamp</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mf">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">clearstamp</span><span class="p">(</span><span class="n">astamp</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.clearstamps">
<tt class="descclassname">turtle.</tt><tt class="descname">clearstamps</tt><big>(</big><em>n=None</em><big>)</big><a class="headerlink" href="#turtle.clearstamps" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>n</em> &#8211; an integer (or <tt class="xref docutils literal"><span class="pre">None</span></tt>)</td>
</tr>
</tbody>
</table>
<p>Delete all or first/last <em>n</em> of turtle&#8217;s stamps.  If <em>n</em> is None, delete
all stamps, if <em>n</em> &gt; 0 delete first <em>n</em> stamps, else if <em>n</em> &lt; 0 delete
last <em>n</em> stamps.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mf">8</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">turtle</span><span class="o">.</span><span class="n">stamp</span><span class="p">();</span> <span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mf">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">clearstamps</span><span class="p">(</span><span class="mf">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">clearstamps</span><span class="p">(</span><span class="o">-</span><span class="mf">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">clearstamps</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.undo">
<tt class="descclassname">turtle.</tt><tt class="descname">undo</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.undo" title="Permalink to this definition">¶</a></dt>
<dd><p>Undo (repeatedly) the last turtle action(s).  Number of available
undo actions is determined by the size of the undobuffer.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mf">4</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mf">50</span><span class="p">);</span> <span class="n">turtle</span><span class="o">.</span><span class="n">lt</span><span class="p">(</span><span class="mf">80</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mf">8</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">turtle</span><span class="o">.</span><span class="n">undo</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.speed">
<tt class="descclassname">turtle.</tt><tt class="descname">speed</tt><big>(</big><em>speed=None</em><big>)</big><a class="headerlink" href="#turtle.speed" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>speed</em> &#8211; an integer in the range 0..10 or a speedstring (see below)</td>
</tr>
</tbody>
</table>
<p>Set the turtle&#8217;s speed to an integer value in the range 0..10.  If no
argument is given, return current speed.</p>
<p>If input is a number greater than 10 or smaller than 0.5, speed is set
to 0.  Speedstrings are mapped to speedvalues as follows:</p>
<ul class="simple">
<li>&#8220;fastest&#8221;:  0</li>
<li>&#8220;fast&#8221;:  10</li>
<li>&#8220;normal&#8221;:  6</li>
<li>&#8220;slow&#8221;:  3</li>
<li>&#8220;slowest&#8221;:  1</li>
</ul>
<p>Speeds from 1 to 10 enforce increasingly faster animation of line drawing
and turtle turning.</p>
<p>Attention: <em>speed</em> = 0 means that <em>no</em> animation takes
place. forward/back makes turtle jump and likewise left/right make the
turtle turn instantly.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">speed</span><span class="p">(</span><span class="mf">3</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="tell-turtle-s-state">
<h3>25.4.3.2. Tell Turtle&#8217;s state<a class="headerlink" href="#tell-turtle-s-state" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.position">
<tt class="descclassname">turtle.</tt><tt class="descname">position</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.position" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.pos">
<tt class="descclassname">turtle.</tt><tt class="descname">pos</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.pos" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the turtle&#8217;s current location (x,y) (as a <a title="turtle.Vec2D" class="reference internal" href="#turtle.Vec2D"><tt class="xref docutils literal"><span class="pre">Vec2D</span></tt></a> vector).</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(0.00, 240.00)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.towards">
<tt class="descclassname">turtle.</tt><tt class="descname">towards</tt><big>(</big><em>x</em>, <em>y=None</em><big>)</big><a class="headerlink" href="#turtle.towards" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>x</em> &#8211; a number or a pair/vector of numbers or a turtle instance</li>
<li><em>y</em> &#8211; a number if <em>x</em> is a number, else <tt class="xref docutils literal"><span class="pre">None</span></tt></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Return the angle between the line from turtle position to position specified
by (x,y), the vector or the other turtle.  This depends on the turtle&#8217;s start
orientation which depends on the mode - &#8220;standard&#8221;/&#8221;world&#8221; or &#8220;logo&#8221;).</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(10.00, 10.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">towards</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="mf">0</span><span class="p">)</span>
<span class="go">225.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.xcor">
<tt class="descclassname">turtle.</tt><tt class="descname">xcor</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.xcor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the turtle&#8217;s x coordinate.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mf">60</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mf">100</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">turtle</span><span class="o">.</span><span class="n">xcor</span><span class="p">()</span>
<span class="go">50.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.ycor">
<tt class="descclassname">turtle.</tt><tt class="descname">ycor</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.ycor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the turtle&#8217;s y coordinate.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mf">60</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mf">100</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">turtle</span><span class="o">.</span><span class="n">ycor</span><span class="p">()</span>
<span class="go">86.6025403784</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.heading">
<tt class="descclassname">turtle.</tt><tt class="descname">heading</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.heading" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the turtle&#8217;s current heading (value depends on the turtle mode, see
<a title="turtle.mode" class="reference internal" href="#turtle.mode"><tt class="xref docutils literal"><span class="pre">mode()</span></tt></a>).</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mf">67</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">67.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.distance">
<tt class="descclassname">turtle.</tt><tt class="descname">distance</tt><big>(</big><em>x</em>, <em>y=None</em><big>)</big><a class="headerlink" href="#turtle.distance" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>x</em> &#8211; a number or a pair/vector of numbers or a turtle instance</li>
<li><em>y</em> &#8211; a number if <em>x</em> is a number, else <tt class="xref docutils literal"><span class="pre">None</span></tt></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Return the distance from the turtle to (x,y), the given vector, or the given
other turtle, in turtle step units.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pos</span><span class="p">()</span>
<span class="go">(0.00, 0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">distance</span><span class="p">(</span><span class="mf">30</span><span class="p">,</span><span class="mf">40</span><span class="p">)</span>
<span class="go">50.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">joe</span> <span class="o">=</span> <span class="n">Turtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">joe</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mf">77</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">distance</span><span class="p">(</span><span class="n">joe</span><span class="p">)</span>
<span class="go">77.0</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="settings-for-measurement">
<h3>25.4.3.3. Settings for measurement<a class="headerlink" href="#settings-for-measurement" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.degrees">
<tt class="descclassname">turtle.</tt><tt class="descname">degrees</tt><big>(</big><em>fullcircle=360.0</em><big>)</big><a class="headerlink" href="#turtle.degrees" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>fullcircle</em> &#8211; a number</td>
</tr>
</tbody>
</table>
<p>Set angle measurement units, i.e. set number of &#8220;degrees&#8221; for a full circle.
Default value is 360 degrees.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mf">90</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">90</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">degrees</span><span class="p">(</span><span class="mf">400.0</span><span class="p">)</span>  <span class="c"># angle measurement in gon</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">100</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.radians">
<tt class="descclassname">turtle.</tt><tt class="descname">radians</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.radians" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the angle measurement units to radians.  Equivalent to
<tt class="docutils literal"><span class="pre">degrees(2*math.pi)</span></tt>.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">90</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">radians</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">1.5707963267948966</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="pen-control">
<h3>25.4.3.4. Pen control<a class="headerlink" href="#pen-control" title="Permalink to this headline">¶</a></h3>
<div class="section" id="drawing-state">
<h4>25.4.3.4.1. Drawing state<a class="headerlink" href="#drawing-state" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.pendown">
<tt class="descclassname">turtle.</tt><tt class="descname">pendown</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.pendown" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.pd">
<tt class="descclassname">turtle.</tt><tt class="descname">pd</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.pd" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.down">
<tt class="descclassname">turtle.</tt><tt class="descname">down</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.down" title="Permalink to this definition">¶</a></dt>
<dd>Pull the pen down &#8211; drawing when moving.</dd></dl>

<dl class="function">
<dt id="turtle.penup">
<tt class="descclassname">turtle.</tt><tt class="descname">penup</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.penup" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.pu">
<tt class="descclassname">turtle.</tt><tt class="descname">pu</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.pu" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.up">
<tt class="descclassname">turtle.</tt><tt class="descname">up</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.up" title="Permalink to this definition">¶</a></dt>
<dd>Pull the pen up &#8211; no drawing when moving.</dd></dl>

<dl class="function">
<dt id="turtle.pensize">
<tt class="descclassname">turtle.</tt><tt class="descname">pensize</tt><big>(</big><em>width=None</em><big>)</big><a class="headerlink" href="#turtle.pensize" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.width">
<tt class="descclassname">turtle.</tt><tt class="descname">width</tt><big>(</big><em>width=None</em><big>)</big><a class="headerlink" href="#turtle.width" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>width</em> &#8211; a positive number</td>
</tr>
</tbody>
</table>
<p>Set the line thickness to <em>width</em> or return it.  If resizemode is set to
&#8220;auto&#8221; and turtleshape is a polygon, that polygon is drawn with the same line
thickness.  If no argument is given, the current pensize is returned.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pensize</span><span class="p">()</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pensize</span><span class="p">(</span><span class="mf">10</span><span class="p">)</span>   <span class="c"># from here on lines of width 10 are drawn</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.pen">
<tt class="descclassname">turtle.</tt><tt class="descname">pen</tt><big>(</big><em>pen=None</em>, <em>**pendict</em><big>)</big><a class="headerlink" href="#turtle.pen" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>pen</em> &#8211; a dictionary with some or all of the below listed keys</li>
<li><em>pendict</em> &#8211; one or more keyword-arguments with the below listed keys as keywords</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Return or set the pen&#8217;s attributes in a &#8220;pen-dictionary&#8221; with the following
key/value pairs:</p>
<ul class="simple">
<li>&#8220;shown&#8221;: True/False</li>
<li>&#8220;pendown&#8221;: True/False</li>
<li>&#8220;pencolor&#8221;: color-string or color-tuple</li>
<li>&#8220;fillcolor&#8221;: color-string or color-tuple</li>
<li>&#8220;pensize&#8221;: positive number</li>
<li>&#8220;speed&#8221;: number in range 0..10</li>
<li>&#8220;resizemode&#8221;: &#8220;auto&#8221; or &#8220;user&#8221; or &#8220;noresize&#8221;</li>
<li>&#8220;stretchfactor&#8221;: (positive number, positive number)</li>
<li>&#8220;outline&#8221;: positive number</li>
<li>&#8220;tilt&#8221;: number</li>
</ul>
<p>This dicionary can be used as argument for a subsequent call to <a title="turtle.pen" class="reference internal" href="#turtle.pen"><tt class="xref docutils literal"><span class="pre">pen()</span></tt></a>
to restore the former pen-state.  Moreover one or more of these attributes
can be provided as keyword-arguments.  This can be used to set several pen
attributes in one statement.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">(</span><span class="n">fillcolor</span><span class="o">=</span><span class="s">&quot;black&quot;</span><span class="p">,</span> <span class="n">pencolor</span><span class="o">=</span><span class="s">&quot;red&quot;</span><span class="p">,</span> <span class="n">pensize</span><span class="o">=</span><span class="mf">10</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">()</span>
<span class="go">{&#39;pensize&#39;: 10, &#39;shown&#39;: True, &#39;resizemode&#39;: &#39;auto&#39;, &#39;outline&#39;: 1,</span>
<span class="go">&#39;pencolor&#39;: &#39;red&#39;, &#39;pendown&#39;: True, &#39;fillcolor&#39;: &#39;black&#39;,</span>
<span class="go">&#39;stretchfactor&#39;: (1,1), &#39;speed&#39;: 3}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">penstate</span><span class="o">=</span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s">&quot;yellow&quot;</span><span class="p">,</span><span class="s">&quot;&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">penup</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pen</span><span class="p">()</span>
<span class="go">{&#39;pensize&#39;: 10, &#39;shown&#39;: True, &#39;resizemode&#39;: &#39;auto&#39;, &#39;outline&#39;: 1,</span>
<span class="go">&#39;pencolor&#39;: &#39;yellow&#39;, &#39;pendown&#39;: False, &#39;fillcolor&#39;: &#39;&#39;,</span>
<span class="go">&#39;stretchfactor&#39;: (1,1), &#39;speed&#39;: 3}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">pen</span><span class="p">(</span><span class="n">penstate</span><span class="p">,</span> <span class="n">fillcolor</span><span class="o">=</span><span class="s">&quot;green&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">pen</span><span class="p">()</span>
<span class="go">{&#39;pensize&#39;: 10, &#39;shown&#39;: True, &#39;resizemode&#39;: &#39;auto&#39;, &#39;outline&#39;: 1,</span>
<span class="go">&#39;pencolor&#39;: &#39;red&#39;, &#39;pendown&#39;: True, &#39;fillcolor&#39;: &#39;green&#39;,</span>
<span class="go">&#39;stretchfactor&#39;: (1,1), &#39;speed&#39;: 3}</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.isdown">
<tt class="descclassname">turtle.</tt><tt class="descname">isdown</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.isdown" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <tt class="xref docutils literal"><span class="pre">True</span></tt> if pen is down, <tt class="xref docutils literal"><span class="pre">False</span></tt> if it&#8217;s up.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">penup</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">isdown</span><span class="p">()</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pendown</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">isdown</span><span class="p">()</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="color-control">
<h4>25.4.3.4.2. Color control<a class="headerlink" href="#color-control" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.pencolor">
<tt class="descclassname">turtle.</tt><tt class="descname">pencolor</tt><big>(</big><em>*args</em><big>)</big><a class="headerlink" href="#turtle.pencolor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return or set the pencolor.</p>
<p>Four input formats are allowed:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">pencolor()</span></tt></dt>
<dd>Return the current pencolor as color specification string, possibly in
hex-number format (see example).  May be used as input to another
color/pencolor/fillcolor call.</dd>
<dt><tt class="docutils literal"><span class="pre">pencolor(colorstring)</span></tt></dt>
<dd>Set pencolor to <em>colorstring</em>, which is a Tk color specification string,
such as <tt class="docutils literal"><span class="pre">&quot;red&quot;</span></tt>, <tt class="docutils literal"><span class="pre">&quot;yellow&quot;</span></tt>, or <tt class="docutils literal"><span class="pre">&quot;#33cc8c&quot;</span></tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">pencolor((r,</span> <span class="pre">g,</span> <span class="pre">b))</span></tt></dt>
<dd>Set pencolor to the RGB color represented by the tuple of <em>r</em>, <em>g</em>, and
<em>b</em>.  Each of <em>r</em>, <em>g</em>, and <em>b</em> must be in the range 0..colormode, where
colormode is either 1.0 or 255 (see <a title="turtle.colormode" class="reference internal" href="#turtle.colormode"><tt class="xref docutils literal"><span class="pre">colormode()</span></tt></a>).</dd>
<dt><tt class="docutils literal"><span class="pre">pencolor(r,</span> <span class="pre">g,</span> <span class="pre">b)</span></tt></dt>
<dd><blockquote class="first">
Set pencolor to the RGB color represented by <em>r</em>, <em>g</em>, and <em>b</em>.  Each of
<em>r</em>, <em>g</em>, and <em>b</em> must be in the range 0..colormode.</blockquote>
<p>If turtleshape is a polygon, the outline of that polygon is drawn with the
newly set pencolor.</p>
<div class="last highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">(</span><span class="s">&quot;brown&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">tup</span> <span class="o">=</span> <span class="p">(</span><span class="mf">0.2</span><span class="p">,</span> <span class="mf">0.8</span><span class="p">,</span> <span class="mf">0.55</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">(</span><span class="n">tup</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="go">&quot;#33cc8c&quot;</span>
</pre></div>
</div>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="turtle.fillcolor">
<tt class="descclassname">turtle.</tt><tt class="descname">fillcolor</tt><big>(</big><em>*args</em><big>)</big><a class="headerlink" href="#turtle.fillcolor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return or set the fillcolor.</p>
<p>Four input formats are allowed:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">fillcolor()</span></tt></dt>
<dd>Return the current fillcolor as color specification string, possibly in
hex-number format (see example).  May be used as input to another
color/pencolor/fillcolor call.</dd>
<dt><tt class="docutils literal"><span class="pre">fillcolor(colorstring)</span></tt></dt>
<dd>Set fillcolor to <em>colorstring</em>, which is a Tk color specification string,
such as <tt class="docutils literal"><span class="pre">&quot;red&quot;</span></tt>, <tt class="docutils literal"><span class="pre">&quot;yellow&quot;</span></tt>, or <tt class="docutils literal"><span class="pre">&quot;#33cc8c&quot;</span></tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">fillcolor((r,</span> <span class="pre">g,</span> <span class="pre">b))</span></tt></dt>
<dd>Set fillcolor to the RGB color represented by the tuple of <em>r</em>, <em>g</em>, and
<em>b</em>.  Each of <em>r</em>, <em>g</em>, and <em>b</em> must be in the range 0..colormode, where
colormode is either 1.0 or 255 (see <a title="turtle.colormode" class="reference internal" href="#turtle.colormode"><tt class="xref docutils literal"><span class="pre">colormode()</span></tt></a>).</dd>
<dt><tt class="docutils literal"><span class="pre">fillcolor(r,</span> <span class="pre">g,</span> <span class="pre">b)</span></tt></dt>
<dd><blockquote class="first">
Set fillcolor to the RGB color represented by <em>r</em>, <em>g</em>, and <em>b</em>.  Each of
<em>r</em>, <em>g</em>, and <em>b</em> must be in the range 0..colormode.</blockquote>
<p>If turtleshape is a polygon, the interior of that polygon is drawn
with the newly set fillcolor.</p>
<div class="last highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="s">&quot;violet&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">col</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="n">col</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span> <span class="o">.</span><span class="mf">5</span><span class="p">,</span> <span class="mf">0</span><span class="p">)</span>
</pre></div>
</div>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="turtle.color">
<tt class="descclassname">turtle.</tt><tt class="descname">color</tt><big>(</big><em>*args</em><big>)</big><a class="headerlink" href="#turtle.color" title="Permalink to this definition">¶</a></dt>
<dd><p>Return or set pencolor and fillcolor.</p>
<p>Several input formats are allowed.  They use 0 to 3 arguments as
follows:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">color()</span></tt></dt>
<dd>Return the current pencolor and the current fillcolor as a pair of color
specification strings as returned by <a title="turtle.pencolor" class="reference internal" href="#turtle.pencolor"><tt class="xref docutils literal"><span class="pre">pencolor()</span></tt></a> and
<a title="turtle.fillcolor" class="reference internal" href="#turtle.fillcolor"><tt class="xref docutils literal"><span class="pre">fillcolor()</span></tt></a>.</dd>
<dt><tt class="docutils literal"><span class="pre">color(colorstring)</span></tt>, <tt class="docutils literal"><span class="pre">color((r,g,b))</span></tt>, <tt class="docutils literal"><span class="pre">color(r,g,b)</span></tt></dt>
<dd>Inputs as in <a title="turtle.pencolor" class="reference internal" href="#turtle.pencolor"><tt class="xref docutils literal"><span class="pre">pencolor()</span></tt></a>, set both, fillcolor and pencolor, to the
given value.</dd>
<dt><tt class="docutils literal"><span class="pre">color(colorstring1,</span> <span class="pre">colorstring2)</span></tt>, <tt class="docutils literal"><span class="pre">color((r1,g1,b1),</span> <span class="pre">(r2,g2,b2))</span></tt></dt>
<dd><blockquote class="first">
Equivalent to <tt class="docutils literal"><span class="pre">pencolor(colorstring1)</span></tt> and <tt class="docutils literal"><span class="pre">fillcolor(colorstring2)</span></tt>
and analogously if the other input format is used.</blockquote>
<p>If turtleshape is a polygon, outline and interior of that polygon is drawn
with the newly set colors.</p>
<div class="last highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s">&quot;red&quot;</span><span class="p">,</span> <span class="s">&quot;green&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">()</span>
<span class="go">(&quot;red&quot;, &quot;green&quot;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">colormode</span><span class="p">(</span><span class="mf">255</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">color</span><span class="p">((</span><span class="mf">40</span><span class="p">,</span> <span class="mf">80</span><span class="p">,</span> <span class="mf">120</span><span class="p">),</span> <span class="p">(</span><span class="mf">160</span><span class="p">,</span> <span class="mf">200</span><span class="p">,</span> <span class="mf">240</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">color</span><span class="p">()</span>
<span class="go">(&quot;#285078&quot;, &quot;#a0c8f0&quot;)</span>
</pre></div>
</div>
</dd>
</dl>
</dd></dl>

<p>See also: Screen method <a title="turtle.colormode" class="reference internal" href="#turtle.colormode"><tt class="xref docutils literal"><span class="pre">colormode()</span></tt></a>.</p>
</div>
<div class="section" id="filling">
<h4>25.4.3.4.3. Filling<a class="headerlink" href="#filling" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.fill">
<tt class="descclassname">turtle.</tt><tt class="descname">fill</tt><big>(</big><em>flag</em><big>)</big><a class="headerlink" href="#turtle.fill" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>flag</em> &#8211; True/False (or 1/0 respectively)</td>
</tr>
</tbody>
</table>
<p>Call <tt class="docutils literal"><span class="pre">fill(True)</span></tt> before drawing the shape you want to fill, and
<tt class="docutils literal"><span class="pre">fill(False)</span></tt> when done.  When used without argument: return fillstate
(<tt class="xref docutils literal"><span class="pre">True</span></tt> if filling, <tt class="xref docutils literal"><span class="pre">False</span></tt> else).</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fill</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mf">3</span><span class="p">):</span>
<span class="gp">... </span>   <span class="n">turtle</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="mf">100</span><span class="p">)</span>
<span class="gp">... </span>   <span class="n">turtle</span><span class="o">.</span><span class="n">left</span><span class="p">(</span><span class="mf">120</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fill</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.begin_fill">
<tt class="descclassname">turtle.</tt><tt class="descname">begin_fill</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.begin_fill" title="Permalink to this definition">¶</a></dt>
<dd><p>Call just before drawing a shape to be filled.  Equivalent to <tt class="docutils literal"><span class="pre">fill(True)</span></tt>.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s">&quot;black&quot;</span><span class="p">,</span> <span class="s">&quot;red&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">begin_fill</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">circle</span><span class="p">(</span><span class="mf">60</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">end_fill</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.end_fill">
<tt class="descclassname">turtle.</tt><tt class="descname">end_fill</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.end_fill" title="Permalink to this definition">¶</a></dt>
<dd>Fill the shape drawn after the last call to <a title="turtle.begin_fill" class="reference internal" href="#turtle.begin_fill"><tt class="xref docutils literal"><span class="pre">begin_fill()</span></tt></a>.  Equivalent
to <tt class="docutils literal"><span class="pre">fill(False)</span></tt>.</dd></dl>

</div>
<div class="section" id="more-drawing-control">
<h4>25.4.3.4.4. More drawing control<a class="headerlink" href="#more-drawing-control" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.reset">
<tt class="descclassname">turtle.</tt><tt class="descname">reset</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.reset" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete the turtle&#8217;s drawings from the screen, re-center the turtle and set
variables to the default values.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,-22.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">100.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">position</span><span class="p">()</span>
<span class="go">(0.00,0.00)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">heading</span><span class="p">()</span>
<span class="go">0.0</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.clear">
<tt class="descclassname">turtle.</tt><tt class="descname">clear</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.clear" title="Permalink to this definition">¶</a></dt>
<dd>Delete the turtle&#8217;s drawings from the screen.  Do not move turtle.  State and
position of the turtle as well as drawings of other turtles are not affected.</dd></dl>

<dl class="function">
<dt id="turtle.write">
<tt class="descclassname">turtle.</tt><tt class="descname">write</tt><big>(</big><em>arg</em>, <em>move=False</em>, <em>align=&quot;left&quot;</em>, <em>font=(&quot;Arial&quot;</em>, <em>8</em>, <em>&quot;normal&quot;)</em><big>)</big><a class="headerlink" href="#turtle.write" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>arg</em> &#8211; object to be written to the TurtleScreen</li>
<li><em>move</em> &#8211; True/False</li>
<li><em>align</em> &#8211; one of the strings &#8220;left&#8221;, &#8220;center&#8221; or right&#8221;</li>
<li><em>font</em> &#8211; a triple (fontname, fontsize, fonttype)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Write text - the string representation of <em>arg</em> - at the current turtle
position according to <em>align</em> (&#8220;left&#8221;, &#8220;center&#8221; or right&#8221;) and with the given
font.  If <em>move</em> is True, the pen is moved to the bottom-right corner of the
text.  By default, <em>move</em> is False.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&quot;Home = &quot;</span><span class="p">,</span> <span class="bp">True</span><span class="p">,</span> <span class="n">align</span><span class="o">=</span><span class="s">&quot;center&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">write</span><span class="p">((</span><span class="mf">0</span><span class="p">,</span><span class="mf">0</span><span class="p">),</span> <span class="bp">True</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>
<div class="section" id="turtle-state">
<h3>25.4.3.5. Turtle state<a class="headerlink" href="#turtle-state" title="Permalink to this headline">¶</a></h3>
<div class="section" id="visibility">
<h4>25.4.3.5.1. Visibility<a class="headerlink" href="#visibility" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.showturtle">
<tt class="descclassname">turtle.</tt><tt class="descname">showturtle</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.showturtle" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.st">
<tt class="descclassname">turtle.</tt><tt class="descname">st</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.st" title="Permalink to this definition">¶</a></dt>
<dd><p>Make the turtle visible.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">hideturtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">showturtle</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.hideturtle">
<tt class="descclassname">turtle.</tt><tt class="descname">hideturtle</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.hideturtle" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.ht">
<tt class="descclassname">turtle.</tt><tt class="descname">ht</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.ht" title="Permalink to this definition">¶</a></dt>
<dd><p>Make the turtle invisible.  It&#8217;s a good idea to do this while you&#8217;re in the
middle of doing some complex drawing, because hiding the turtle speeds up the
drawing observably.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">hideturtle</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.isvisible">
<tt class="descclassname">turtle.</tt><tt class="descname">isvisible</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.isvisible" title="Permalink to this definition">¶</a></dt>
<dd><p>Return True if the Turtle is shown, False if it&#8217;s hidden.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">hideturtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">turtle</span><span class="o">.</span><span class="n">isvisible</span><span class="p">():</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="appearance">
<h4>25.4.3.5.2. Appearance<a class="headerlink" href="#appearance" title="Permalink to this headline">¶</a></h4>
<dl class="function">
<dt id="turtle.shape">
<tt class="descclassname">turtle.</tt><tt class="descname">shape</tt><big>(</big><em>name=None</em><big>)</big><a class="headerlink" href="#turtle.shape" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>name</em> &#8211; a string which is a valid shapename</td>
</tr>
</tbody>
</table>
<p>Set turtle shape to shape with given <em>name</em> or, if name is not given, return
name of current shape.  Shape with <em>name</em> must exist in the TurtleScreen&#8217;s
shape dictionary.  Initially there are the following polygon shapes: &#8220;arrow&#8221;,
&#8220;turtle&#8221;, &#8220;circle&#8221;, &#8220;square&#8221;, &#8220;triangle&#8221;, &#8220;classic&#8221;.  To learn about how to
deal with shapes see Screen method <a title="turtle.register_shape" class="reference internal" href="#turtle.register_shape"><tt class="xref docutils literal"><span class="pre">register_shape()</span></tt></a>.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">()</span>
<span class="go">&quot;arrow&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s">&quot;turtle&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">()</span>
<span class="go">&quot;turtle&quot;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.resizemode">
<tt class="descclassname">turtle.</tt><tt class="descname">resizemode</tt><big>(</big><em>rmode=None</em><big>)</big><a class="headerlink" href="#turtle.resizemode" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>rmode</em> &#8211; one of the strings &#8220;auto&#8221;, &#8220;user&#8221;, &#8220;noresize&#8221;</td>
</tr>
</tbody>
</table>
<p>Set resizemode to one of the values: &#8220;auto&#8221;, &#8220;user&#8221;, &#8220;noresize&#8221;.  If <em>rmode</em>
is not given, return current resizemode.  Different resizemodes have the
following effects:</p>
<ul class="simple">
<li>&#8220;auto&#8221;: adapts the appearance of the turtle corresponding to the value of pensize.</li>
<li>&#8220;user&#8221;: adapts the appearance of the turtle according to the values of
stretchfactor and outlinewidth (outline), which are set by
<a title="turtle.shapesize" class="reference internal" href="#turtle.shapesize"><tt class="xref docutils literal"><span class="pre">shapesize()</span></tt></a>.</li>
<li>&#8220;noresize&#8221;: no adaption of the turtle&#8217;s appearance takes place.</li>
</ul>
<p>resizemode(&#8220;user&#8221;) is called by <a title="turtle.shapesize" class="reference internal" href="#turtle.shapesize"><tt class="xref docutils literal"><span class="pre">shapesize()</span></tt></a> when used with arguments.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">resizemode</span><span class="p">(</span><span class="s">&quot;noresize&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">resizemode</span><span class="p">()</span>
<span class="go">&quot;noresize&quot;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.shapesize">
<tt class="descclassname">turtle.</tt><tt class="descname">shapesize</tt><big>(</big><em>stretch_wid=None</em>, <em>stretch_len=None</em>, <em>outline=None</em><big>)</big><a class="headerlink" href="#turtle.shapesize" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>stretch_wid</em> &#8211; positive number</li>
<li><em>stretch_len</em> &#8211; positive number</li>
<li><em>outline</em> &#8211; positive number</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Return or set the pen&#8217;s attributes x/y-stretchfactors and/or outline.  Set
resizemode to &#8220;user&#8221;.  If and only if resizemode is set to &#8220;user&#8221;, the turtle
will be displayed stretched according to its stretchfactors: <em>stretch_wid</em> is
stretchfactor perpendicular to its orientation, <em>stretch_len</em> is
stretchfactor in direction of its orientation, <em>outline</em> determines the width
of the shapes&#8217;s outline.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">resizemode</span><span class="p">(</span><span class="s">&quot;user&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mf">5</span><span class="p">,</span> <span class="mf">5</span><span class="p">,</span> <span class="mf">12</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="n">outline</span><span class="o">=</span><span class="mf">8</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.tilt">
<tt class="descclassname">turtle.</tt><tt class="descname">tilt</tt><big>(</big><em>angle</em><big>)</big><a class="headerlink" href="#turtle.tilt" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>angle</em> &#8211; a number</td>
</tr>
</tbody>
</table>
<p>Rotate the turtleshape by <em>angle</em> from its current tilt-angle, but do <em>not</em>
change the turtle&#8217;s heading (direction of movement).</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s">&quot;circle&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mf">5</span><span class="p">,</span><span class="mf">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">tilt</span><span class="p">(</span><span class="mf">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mf">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">tilt</span><span class="p">(</span><span class="mf">30</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mf">50</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.settiltangle">
<tt class="descclassname">turtle.</tt><tt class="descname">settiltangle</tt><big>(</big><em>angle</em><big>)</big><a class="headerlink" href="#turtle.settiltangle" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>angle</em> &#8211; a number</td>
</tr>
</tbody>
</table>
<p>Rotate the turtleshape to point in the direction specified by <em>angle</em>,
regardless of its current tilt-angle.  <em>Do not</em> change the turtle&#8217;s heading
(direction of movement).</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s">&quot;circle&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mf">5</span><span class="p">,</span><span class="mf">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">settiltangle</span><span class="p">(</span><span class="mf">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">stamp</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mf">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">settiltangle</span><span class="p">(</span><span class="o">-</span><span class="mf">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">stamp</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mf">50</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.tiltangle">
<tt class="descclassname">turtle.</tt><tt class="descname">tiltangle</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.tiltangle" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the current tilt-angle, i.e. the angle between the orientation of the
turtleshape and the heading of the turtle (its direction of movement).</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shape</span><span class="p">(</span><span class="s">&quot;circle&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">shapesize</span><span class="p">(</span><span class="mf">5</span><span class="p">,</span><span class="mf">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">tilt</span><span class="p">(</span><span class="mf">45</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">tiltangle</span><span class="p">()</span>
<span class="go">45</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>
<div class="section" id="using-events">
<h3>25.4.3.6. Using events<a class="headerlink" href="#using-events" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.onclick">
<tt class="descclassname">turtle.</tt><tt class="descname">onclick</tt><big>(</big><em>fun</em>, <em>btn=1</em>, <em>add=None</em><big>)</big><a class="headerlink" href="#turtle.onclick" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>fun</em> &#8211; a function with two arguments which will be called with the
coordinates of the clicked point on the canvas</li>
<li><em>num</em> &#8211; number of the mouse-button, defaults to 1 (left mouse button)</li>
<li><em>add</em> &#8211; <tt class="xref docutils literal"><span class="pre">True</span></tt> or <tt class="xref docutils literal"><span class="pre">False</span></tt> &#8211; if <tt class="xref docutils literal"><span class="pre">True</span></tt>, a new binding will be
added, otherwise it will replace a former binding</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to mouse-click events on this turtle.  If <em>fun</em> is <tt class="xref docutils literal"><span class="pre">None</span></tt>,
existing bindings are removed.  Example for the anonymous turtle, i.e. the
procedural way:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">turn</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">left</span><span class="p">(</span><span class="mf">180</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">onclick</span><span class="p">(</span><span class="n">turn</span><span class="p">)</span>  <span class="c"># Now clicking into the turtle will turn it.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">onclick</span><span class="p">(</span><span class="bp">None</span><span class="p">)</span>  <span class="c"># event-binding will be removed</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.onrelease">
<tt class="descclassname">turtle.</tt><tt class="descname">onrelease</tt><big>(</big><em>fun</em>, <em>btn=1</em>, <em>add=None</em><big>)</big><a class="headerlink" href="#turtle.onrelease" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>fun</em> &#8211; a function with two arguments which will be called with the
coordinates of the clicked point on the canvas</li>
<li><em>num</em> &#8211; number of the mouse-button, defaults to 1 (left mouse button)</li>
<li><em>add</em> &#8211; <tt class="xref docutils literal"><span class="pre">True</span></tt> or <tt class="xref docutils literal"><span class="pre">False</span></tt> &#8211; if <tt class="xref docutils literal"><span class="pre">True</span></tt>, a new binding will be
added, otherwise it will replace a former binding</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to mouse-button-release events on this turtle.  If <em>fun</em> is
<tt class="xref docutils literal"><span class="pre">None</span></tt>, existing bindings are removed.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">class</span> <span class="nc">MyTurtle</span><span class="p">(</span><span class="n">Turtle</span><span class="p">):</span>
<span class="gp">... </span>    <span class="k">def</span> <span class="nf">glow</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">):</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="s">&quot;red&quot;</span><span class="p">)</span>
<span class="gp">... </span>    <span class="k">def</span> <span class="nf">unglow</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">):</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">fillcolor</span><span class="p">(</span><span class="s">&quot;&quot;</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span> <span class="o">=</span> <span class="n">MyTurtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">onclick</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">glow</span><span class="p">)</span>     <span class="c"># clicking on turtle turns fillcolor red,</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">onrelease</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">unglow</span><span class="p">)</span> <span class="c"># releasing turns it to transparent.</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.ondrag">
<tt class="descclassname">turtle.</tt><tt class="descname">ondrag</tt><big>(</big><em>fun</em>, <em>btn=1</em>, <em>add=None</em><big>)</big><a class="headerlink" href="#turtle.ondrag" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>fun</em> &#8211; a function with two arguments which will be called with the
coordinates of the clicked point on the canvas</li>
<li><em>num</em> &#8211; number of the mouse-button, defaults to 1 (left mouse button)</li>
<li><em>add</em> &#8211; <tt class="xref docutils literal"><span class="pre">True</span></tt> or <tt class="xref docutils literal"><span class="pre">False</span></tt> &#8211; if <tt class="xref docutils literal"><span class="pre">True</span></tt>, a new binding will be
added, otherwise it will replace a former binding</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to mouse-move events on this turtle.  If <em>fun</em> is <tt class="xref docutils literal"><span class="pre">None</span></tt>,
existing bindings are removed.</p>
<p>Remark: Every sequence of mouse-move-events on a turtle is preceded by a
mouse-click event on that turtle.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">ondrag</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">goto</span><span class="p">)</span>
<span class="go"># Subsequently, clicking and dragging the Turtle will move it across</span>
<span class="go"># the screen thereby producing handdrawings (if pen is down).</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="special-turtle-methods">
<h3>25.4.3.7. Special Turtle methods<a class="headerlink" href="#special-turtle-methods" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.begin_poly">
<tt class="descclassname">turtle.</tt><tt class="descname">begin_poly</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.begin_poly" title="Permalink to this definition">¶</a></dt>
<dd>Start recording the vertices of a polygon.  Current turtle position is first
vertex of polygon.</dd></dl>

<dl class="function">
<dt id="turtle.end_poly">
<tt class="descclassname">turtle.</tt><tt class="descname">end_poly</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.end_poly" title="Permalink to this definition">¶</a></dt>
<dd>Stop recording the vertices of a polygon.  Current turtle position is last
vertex of polygon.  This will be connected with the first vertex.</dd></dl>

<dl class="function">
<dt id="turtle.get_poly">
<tt class="descclassname">turtle.</tt><tt class="descname">get_poly</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.get_poly" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the last recorded polygon.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">get_poly</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">register_shape</span><span class="p">(</span><span class="s">&quot;myFavouriteShape&quot;</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.clone">
<tt class="descclassname">turtle.</tt><tt class="descname">clone</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.clone" title="Permalink to this definition">¶</a></dt>
<dd><p>Create and return a clone of the turtle with same position, heading and
turtle properties.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">mick</span> <span class="o">=</span> <span class="n">Turtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">joe</span> <span class="o">=</span> <span class="n">mick</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.getturtle">
<tt class="descclassname">turtle.</tt><tt class="descname">getturtle</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.getturtle" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the Turtle object itself.  Only reasonable use: as a function to
return the &#8220;anonymous turtle&#8221;:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">pet</span> <span class="o">=</span> <span class="n">getturtle</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pet</span><span class="o">.</span><span class="n">fd</span><span class="p">(</span><span class="mf">50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pet</span>
<span class="go">&lt;turtle.Turtle object at 0x01417350&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtles</span><span class="p">()</span>
<span class="go">[&lt;turtle.Turtle object at 0x01417350&gt;]</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.getscreen">
<tt class="descclassname">turtle.</tt><tt class="descname">getscreen</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.getscreen" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the <a title="turtle.TurtleScreen" class="reference internal" href="#turtle.TurtleScreen"><tt class="xref docutils literal"><span class="pre">TurtleScreen</span></tt></a> object the turtle is drawing on.
TurtleScreen methods can then be called for that object.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">ts</span> <span class="o">=</span> <span class="n">turtle</span><span class="o">.</span><span class="n">getscreen</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ts</span>
<span class="go">&lt;turtle.Screen object at 0x01417710&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ts</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">(</span><span class="s">&quot;pink&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.setundobuffer">
<tt class="descclassname">turtle.</tt><tt class="descname">setundobuffer</tt><big>(</big><em>size</em><big>)</big><a class="headerlink" href="#turtle.setundobuffer" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>size</em> &#8211; an integer or <tt class="xref docutils literal"><span class="pre">None</span></tt></td>
</tr>
</tbody>
</table>
<p>Set or disable undobuffer.  If <em>size</em> is an integer an empty undobuffer of
given size is installed.  <em>size</em> gives the maximum number of turtle actions
that can be undone by the <a title="turtle.undo" class="reference internal" href="#turtle.undo"><tt class="xref docutils literal"><span class="pre">undo()</span></tt></a> method/function.  If <em>size</em> is
<tt class="xref docutils literal"><span class="pre">None</span></tt>, the undobuffer is disabled.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">setundobuffer</span><span class="p">(</span><span class="mf">42</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.undobufferentries">
<tt class="descclassname">turtle.</tt><tt class="descname">undobufferentries</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.undobufferentries" title="Permalink to this definition">¶</a></dt>
<dd><p>Return number of entries in the undobuffer.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">while</span> <span class="n">undobufferentries</span><span class="p">():</span>
<span class="gp">... </span>    <span class="n">undo</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.tracer">
<tt class="descclassname">turtle.</tt><tt class="descname">tracer</tt><big>(</big><em>flag=None</em>, <em>delay=None</em><big>)</big><a class="headerlink" href="#turtle.tracer" title="Permalink to this definition">¶</a></dt>
<dd><p>A replica of the corresponding TurtleScreen method.</p>
<p>
<span class="versionmodified">Deprecated since version 2.6.</span></p>
</dd></dl>

<dl class="function">
<dt id="turtle.window_width">
<tt class="descclassname">turtle.</tt><tt class="descname">window_width</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.window_width" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.window_height">
<tt class="descclassname">turtle.</tt><tt class="descname">window_height</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.window_height" title="Permalink to this definition">¶</a></dt>
<dd><p>Both are replicas of the corresponding TurtleScreen methods.</p>
<p>
<span class="versionmodified">Deprecated since version 2.6.</span></p>
</dd></dl>

</div>
<div class="section" id="excursus-about-the-use-of-compound-shapes">
<span id="compoundshapes"></span><h3>25.4.3.8. Excursus about the use of compound shapes<a class="headerlink" href="#excursus-about-the-use-of-compound-shapes" title="Permalink to this headline">¶</a></h3>
<p>To use compound turtle shapes, which consist of several polygons of different
color, you must use the helper class <a title="turtle.Shape" class="reference internal" href="#turtle.Shape"><tt class="xref docutils literal"><span class="pre">Shape</span></tt></a> explicitly as described
below:</p>
<ol class="arabic">
<li><p class="first">Create an empty Shape object of type &#8220;compound&#8221;.</p>
</li>
<li><p class="first">Add as many components to this object as desired, using the
<tt class="xref docutils literal"><span class="pre">addcomponent()</span></tt> method.</p>
<p>For example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">Shape</span><span class="p">(</span><span class="s">&quot;compound&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly1</span> <span class="o">=</span> <span class="p">((</span><span class="mf">0</span><span class="p">,</span><span class="mf">0</span><span class="p">),(</span><span class="mf">10</span><span class="p">,</span><span class="o">-</span><span class="mf">5</span><span class="p">),(</span><span class="mf">0</span><span class="p">,</span><span class="mf">10</span><span class="p">),(</span><span class="o">-</span><span class="mf">10</span><span class="p">,</span><span class="o">-</span><span class="mf">5</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">addcomponent</span><span class="p">(</span><span class="n">poly1</span><span class="p">,</span> <span class="s">&quot;red&quot;</span><span class="p">,</span> <span class="s">&quot;blue&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly2</span> <span class="o">=</span> <span class="p">((</span><span class="mf">0</span><span class="p">,</span><span class="mf">0</span><span class="p">),(</span><span class="mf">10</span><span class="p">,</span><span class="o">-</span><span class="mf">5</span><span class="p">),(</span><span class="o">-</span><span class="mf">10</span><span class="p">,</span><span class="o">-</span><span class="mf">5</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">addcomponent</span><span class="p">(</span><span class="n">poly2</span><span class="p">,</span> <span class="s">&quot;blue&quot;</span><span class="p">,</span> <span class="s">&quot;red&quot;</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">Now add the Shape to the Screen&#8217;s shapelist and use it:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">register_shape</span><span class="p">(</span><span class="s">&quot;myshape&quot;</span><span class="p">,</span> <span class="n">s</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">shape</span><span class="p">(</span><span class="s">&quot;myshape&quot;</span><span class="p">)</span>
</pre></div>
</div>
</li>
</ol>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The <a title="turtle.Shape" class="reference internal" href="#turtle.Shape"><tt class="xref docutils literal"><span class="pre">Shape</span></tt></a> class is used internally by the <a title="turtle.register_shape" class="reference internal" href="#turtle.register_shape"><tt class="xref docutils literal"><span class="pre">register_shape()</span></tt></a>
method in different ways.  The application programmer has to deal with the
Shape class <em>only</em> when using compound shapes like shown above!</p>
</div>
</div>
</div>
<div class="section" id="methods-of-turtlescreen-screen-and-corresponding-functions">
<h2>25.4.4. Methods of TurtleScreen/Screen and corresponding functions<a class="headerlink" href="#methods-of-turtlescreen-screen-and-corresponding-functions" title="Permalink to this headline">¶</a></h2>
<p>Most of the examples in this section refer to a TurtleScreen instance called
<tt class="docutils literal"><span class="pre">screen</span></tt>.</p>
<div class="section" id="window-control">
<h3>25.4.4.1. Window control<a class="headerlink" href="#window-control" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.bgcolor">
<tt class="descclassname">turtle.</tt><tt class="descname">bgcolor</tt><big>(</big><em>*args</em><big>)</big><a class="headerlink" href="#turtle.bgcolor" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>args</em> &#8211; a color string or three numbers in the range 0..colormode or a
3-tuple of such numbers</td>
</tr>
</tbody>
</table>
<p>Set or return background color of the TurtleScreen.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">(</span><span class="s">&quot;orange&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">()</span>
<span class="go">&quot;orange&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">(</span><span class="mf">0.5</span><span class="p">,</span><span class="mf">0</span><span class="p">,</span><span class="mf">0.5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">()</span>
<span class="go">&quot;#800080&quot;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.bgpic">
<tt class="descclassname">turtle.</tt><tt class="descname">bgpic</tt><big>(</big><em>picname=None</em><big>)</big><a class="headerlink" href="#turtle.bgpic" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>picname</em> &#8211; a string, name of a gif-file or <tt class="docutils literal"><span class="pre">&quot;nopic&quot;</span></tt>, or <tt class="xref docutils literal"><span class="pre">None</span></tt></td>
</tr>
</tbody>
</table>
<p>Set background image or return name of current backgroundimage.  If <em>picname</em>
is a filename, set the corresponding image as background.  If <em>picname</em> is
<tt class="docutils literal"><span class="pre">&quot;nopic&quot;</span></tt>, delete background image, if present.  If <em>picname</em> is <tt class="xref docutils literal"><span class="pre">None</span></tt>,
return the filename of the current backgroundimage.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgpic</span><span class="p">()</span>
<span class="go">&quot;nopic&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgpic</span><span class="p">(</span><span class="s">&quot;landscape.gif&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">bgpic</span><span class="p">()</span>
<span class="go">&quot;landscape.gif&quot;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<tt class="descclassname">turtle.</tt><tt class="descname">clear</tt><big>(</big><big>)</big></dt>
<dt id="turtle.clearscreen">
<tt class="descclassname">turtle.</tt><tt class="descname">clearscreen</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.clearscreen" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete all drawings and all turtles from the TurtleScreen.  Reset the now
empty TurtleScreen to its initial state: white background, no background
image, no event bindings and tracing on.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This TurtleScreen method is available as a global function only under the
name <tt class="docutils literal"><span class="pre">clearscreen</span></tt>.  The global function <tt class="docutils literal"><span class="pre">clear</span></tt> is another one
derived from the Turtle method <tt class="docutils literal"><span class="pre">clear</span></tt>.</p>
</div>
</dd></dl>

<dl class="function">
<dt>
<tt class="descclassname">turtle.</tt><tt class="descname">reset</tt><big>(</big><big>)</big></dt>
<dt id="turtle.resetscreen">
<tt class="descclassname">turtle.</tt><tt class="descname">resetscreen</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.resetscreen" title="Permalink to this definition">¶</a></dt>
<dd><p>Reset all Turtles on the Screen to their initial state.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This TurtleScreen method is available as a global function only under the
name <tt class="docutils literal"><span class="pre">resetscreen</span></tt>.  The global function <tt class="docutils literal"><span class="pre">reset</span></tt> is another one
derived from the Turtle method <tt class="docutils literal"><span class="pre">reset</span></tt>.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.screensize">
<tt class="descclassname">turtle.</tt><tt class="descname">screensize</tt><big>(</big><em>canvwidth=None</em>, <em>canvheight=None</em>, <em>bg=None</em><big>)</big><a class="headerlink" href="#turtle.screensize" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>canvwidth</em> &#8211; positive integer, new width of canvas in pixels</li>
<li><em>canvheight</em> &#8211; positive integer, new height of canvas in pixels</li>
<li><em>bg</em> &#8211; colorstring or color-tupel, new background color</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>If no arguments are given, return current (canvaswidth, canvasheight).  Else
resize the canvas the turtles are drawing on.  Do not alter the drawing
window.  To observe hidden parts of the canvas, use the scrollbars. With this
method, one can make visible those parts of a drawing which were outside the
canvas before.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">screensize</span><span class="p">(</span><span class="mf">2000</span><span class="p">,</span><span class="mf">1500</span><span class="p">)</span>
<span class="go"># e.g. to search for an erroneously escaped turtle ;-)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.setworldcoordinates">
<tt class="descclassname">turtle.</tt><tt class="descname">setworldcoordinates</tt><big>(</big><em>llx</em>, <em>lly</em>, <em>urx</em>, <em>ury</em><big>)</big><a class="headerlink" href="#turtle.setworldcoordinates" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>llx</em> &#8211; a number, x-coordinate of lower left corner of canvas</li>
<li><em>lly</em> &#8211; a number, y-coordinate of lower left corner of canvas</li>
<li><em>urx</em> &#8211; a number, x-coordinate of upper right corner of canvas</li>
<li><em>ury</em> &#8211; a number, y-coordinate of upper right corner of canvas</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Set up user-defined coordinate system and switch to mode &#8220;world&#8221; if
necessary.  This performs a <tt class="docutils literal"><span class="pre">screen.reset()</span></tt>.  If mode &#8220;world&#8221; is already
active, all drawings are redrawn according to the new coordinates.</p>
<p><strong>ATTENTION</strong>: in user-defined coordinate systems angles may appear
distorted.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">setworldcoordinates</span><span class="p">(</span><span class="o">-</span><span class="mf">50</span><span class="p">,</span><span class="o">-</span><span class="mf">7.5</span><span class="p">,</span><span class="mf">50</span><span class="p">,</span><span class="mf">7.5</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mf">72</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">left</span><span class="p">(</span><span class="mf">10</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mf">8</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">left</span><span class="p">(</span><span class="mf">45</span><span class="p">);</span> <span class="n">fd</span><span class="p">(</span><span class="mf">2</span><span class="p">)</span>   <span class="c"># a regular octagon</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="animation-control">
<h3>25.4.4.2. Animation control<a class="headerlink" href="#animation-control" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.delay">
<tt class="descclassname">turtle.</tt><tt class="descname">delay</tt><big>(</big><em>delay=None</em><big>)</big><a class="headerlink" href="#turtle.delay" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>delay</em> &#8211; positive integer</td>
</tr>
</tbody>
</table>
<p>Set or return the drawing <em>delay</em> in milliseconds.  (This is approximately
the time interval between two consecutive canvas updates.)  The longer the
drawing delay, the slower the animation.</p>
<p>Optional argument:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">delay</span><span class="p">(</span><span class="mf">15</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">delay</span><span class="p">()</span>
<span class="go">15</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<tt class="descclassname">turtle.</tt><tt class="descname">tracer</tt><big>(</big><em>n=None</em>, <em>delay=None</em><big>)</big></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>n</em> &#8211; nonnegative integer</li>
<li><em>delay</em> &#8211; nonnegative integer</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Turn turtle animation on/off and set delay for update drawings.  If <em>n</em> is
given, only each n-th regular screen update is really performed.  (Can be
used to accelerate the drawing of complex graphics.)  Second argument sets
delay value (see <a title="turtle.delay" class="reference internal" href="#turtle.delay"><tt class="xref docutils literal"><span class="pre">delay()</span></tt></a>).</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">tracer</span><span class="p">(</span><span class="mf">8</span><span class="p">,</span> <span class="mf">25</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dist</span> <span class="o">=</span> <span class="mf">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mf">200</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">fd</span><span class="p">(</span><span class="n">dist</span><span class="p">)</span>
<span class="gp">... </span>    <span class="n">rt</span><span class="p">(</span><span class="mf">90</span><span class="p">)</span>
<span class="gp">... </span>    <span class="n">dist</span> <span class="o">+=</span> <span class="mf">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.update">
<tt class="descclassname">turtle.</tt><tt class="descname">update</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.update" title="Permalink to this definition">¶</a></dt>
<dd>Perform a TurtleScreen update. To be used when tracer is turned off.</dd></dl>

<p>See also the RawTurtle/Turtle method <a title="turtle.speed" class="reference internal" href="#turtle.speed"><tt class="xref docutils literal"><span class="pre">speed()</span></tt></a>.</p>
</div>
<div class="section" id="using-screen-events">
<h3>25.4.4.3. Using screen events<a class="headerlink" href="#using-screen-events" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.listen">
<tt class="descclassname">turtle.</tt><tt class="descname">listen</tt><big>(</big><em>xdummy=None</em>, <em>ydummy=None</em><big>)</big><a class="headerlink" href="#turtle.listen" title="Permalink to this definition">¶</a></dt>
<dd>Set focus on TurtleScreen (in order to collect key-events).  Dummy arguments
are provided in order to be able to pass <a title="turtle.listen" class="reference internal" href="#turtle.listen"><tt class="xref docutils literal"><span class="pre">listen()</span></tt></a> to the onclick method.</dd></dl>

<dl class="function">
<dt id="turtle.onkey">
<tt class="descclassname">turtle.</tt><tt class="descname">onkey</tt><big>(</big><em>fun</em>, <em>key</em><big>)</big><a class="headerlink" href="#turtle.onkey" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>fun</em> &#8211; a function with no arguments or <tt class="xref docutils literal"><span class="pre">None</span></tt></li>
<li><em>key</em> &#8211; a string: key (e.g. &#8220;a&#8221;) or key-symbol (e.g. &#8220;space&#8221;)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to key-release event of key.  If <em>fun</em> is <tt class="xref docutils literal"><span class="pre">None</span></tt>, event bindings
are removed. Remark: in order to be able to register key-events, TurtleScreen
must have the focus. (See method <a title="turtle.listen" class="reference internal" href="#turtle.listen"><tt class="xref docutils literal"><span class="pre">listen()</span></tt></a>.)</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">f</span><span class="p">():</span>
<span class="gp">... </span>    <span class="n">fd</span><span class="p">(</span><span class="mf">50</span><span class="p">)</span>
<span class="gp">... </span>    <span class="n">lt</span><span class="p">(</span><span class="mf">60</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">onkey</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="s">&quot;Up&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">listen</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<tt class="descclassname">turtle.</tt><tt class="descname">onclick</tt><big>(</big><em>fun</em>, <em>btn=1</em>, <em>add=None</em><big>)</big></dt>
<dt id="turtle.onscreenclick">
<tt class="descclassname">turtle.</tt><tt class="descname">onscreenclick</tt><big>(</big><em>fun</em>, <em>btn=1</em>, <em>add=None</em><big>)</big><a class="headerlink" href="#turtle.onscreenclick" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>fun</em> &#8211; a function with two arguments which will be called with the
coordinates of the clicked point on the canvas</li>
<li><em>num</em> &#8211; number of the mouse-button, defaults to 1 (left mouse button)</li>
<li><em>add</em> &#8211; <tt class="xref docutils literal"><span class="pre">True</span></tt> or <tt class="xref docutils literal"><span class="pre">False</span></tt> &#8211; if <tt class="xref docutils literal"><span class="pre">True</span></tt>, a new binding will be
added, otherwise it will replace a former binding</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Bind <em>fun</em> to mouse-click events on this screen.  If <em>fun</em> is <tt class="xref docutils literal"><span class="pre">None</span></tt>,
existing bindings are removed.</p>
<p>Example for a TurtleScreen instance named <tt class="docutils literal"><span class="pre">screen</span></tt> and a Turtle instance
named turtle:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">onclick</span><span class="p">(</span><span class="n">turtle</span><span class="o">.</span><span class="n">goto</span><span class="p">)</span>
<span class="go"># Subsequently clicking into the TurtleScreen will</span>
<span class="go"># make the turtle move to the clicked point.</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">onclick</span><span class="p">(</span><span class="bp">None</span><span class="p">)</span>  <span class="c"># remove event binding again</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This TurtleScreen method is available as a global function only under the
name <tt class="docutils literal"><span class="pre">onscreenclick</span></tt>.  The global function <tt class="docutils literal"><span class="pre">onclick</span></tt> is another one
derived from the Turtle method <tt class="docutils literal"><span class="pre">onclick</span></tt>.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.ontimer">
<tt class="descclassname">turtle.</tt><tt class="descname">ontimer</tt><big>(</big><em>fun</em>, <em>t=0</em><big>)</big><a class="headerlink" href="#turtle.ontimer" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>fun</em> &#8211; a function with no arguments</li>
<li><em>t</em> &#8211; a number &gt;= 0</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Install a timer that calls <em>fun</em> after <em>t</em> milliseconds.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">running</span> <span class="o">=</span> <span class="bp">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">f</span><span class="p">():</span>
<span class="go">        if running:</span>
<span class="go">            fd(50)</span>
<span class="go">            lt(60)</span>
<span class="go">            screen.ontimer(f, 250)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="p">()</span>   <span class="c">### makes the turtle marching around</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">running</span> <span class="o">=</span> <span class="bp">False</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="settings-and-special-methods">
<h3>25.4.4.4. Settings and special methods<a class="headerlink" href="#settings-and-special-methods" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.mode">
<tt class="descclassname">turtle.</tt><tt class="descname">mode</tt><big>(</big><em>mode=None</em><big>)</big><a class="headerlink" href="#turtle.mode" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>mode</em> &#8211; one of the strings &#8220;standard&#8221;, &#8220;logo&#8221; or &#8220;world&#8221;</td>
</tr>
</tbody>
</table>
<p>Set turtle mode (&#8220;standard&#8221;, &#8220;logo&#8221; or &#8220;world&#8221;) and perform reset.  If mode
is not given, current mode is returned.</p>
<p>Mode &#8220;standard&#8221; is compatible with old <tt class="xref docutils literal"><span class="pre">turtle</span></tt>.  Mode &#8220;logo&#8221; is
compatible with most Logo turtle graphics.  Mode &#8220;world&#8221; uses user-defined
&#8220;world coordinates&#8221;. <strong>Attention</strong>: in this mode angles appear distorted if
<tt class="docutils literal"><span class="pre">x/y</span></tt> unit-ratio doesn&#8217;t equal 1.</p>
<table border="1" class="docutils">
<colgroup>
<col width="21%" />
<col width="45%" />
<col width="34%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Mode</th>
<th class="head">Initial turtle heading</th>
<th class="head">positive angles</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>&#8220;standard&#8221;</td>
<td>to the right (east)</td>
<td>counterclockwise</td>
</tr>
<tr><td>&#8220;logo&#8221;</td>
<td>upward    (north)</td>
<td>clockwise</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">mode</span><span class="p">(</span><span class="s">&quot;logo&quot;</span><span class="p">)</span>   <span class="c"># resets turtle heading to north</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mode</span><span class="p">()</span>
<span class="go">&quot;logo&quot;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.colormode">
<tt class="descclassname">turtle.</tt><tt class="descname">colormode</tt><big>(</big><em>cmode=None</em><big>)</big><a class="headerlink" href="#turtle.colormode" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>cmode</em> &#8211; one of the values 1.0 or 255</td>
</tr>
</tbody>
</table>
<p>Return the colormode or set it to 1.0 or 255.  Subsequently <em>r</em>, <em>g</em>, <em>b</em>
values of color triples have to be in the range 0..<em>cmode</em>.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">colormode</span><span class="p">()</span>
<span class="go">1.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">colormode</span><span class="p">(</span><span class="mf">255</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">turtle</span><span class="o">.</span><span class="n">pencolor</span><span class="p">(</span><span class="mf">240</span><span class="p">,</span><span class="mf">160</span><span class="p">,</span><span class="mf">80</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.getcanvas">
<tt class="descclassname">turtle.</tt><tt class="descname">getcanvas</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.getcanvas" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the Canvas of this TurtleScreen.  Useful for insiders who know what to
do with a Tkinter Canvas.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">cv</span> <span class="o">=</span> <span class="n">screen</span><span class="o">.</span><span class="n">getcanvas</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cv</span>
<span class="go">&lt;turtle.ScrolledCanvas instance at 0x010742D8&gt;</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.getshapes">
<tt class="descclassname">turtle.</tt><tt class="descname">getshapes</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.getshapes" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of names of all currently available turtle shapes.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">getshapes</span><span class="p">()</span>
<span class="go">[&quot;arrow&quot;, &quot;blank&quot;, &quot;circle&quot;, ..., &quot;turtle&quot;]</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.register_shape">
<tt class="descclassname">turtle.</tt><tt class="descname">register_shape</tt><big>(</big><em>name</em>, <em>shape=None</em><big>)</big><a class="headerlink" href="#turtle.register_shape" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.addshape">
<tt class="descclassname">turtle.</tt><tt class="descname">addshape</tt><big>(</big><em>name</em>, <em>shape=None</em><big>)</big><a class="headerlink" href="#turtle.addshape" title="Permalink to this definition">¶</a></dt>
<dd><p>There are three different ways to call this function:</p>
<ol class="arabic">
<li><p class="first"><em>name</em> is the name of a gif-file and <em>shape</em> is <tt class="xref docutils literal"><span class="pre">None</span></tt>: Install the
corresponding image shape.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Image shapes <em>do not</em> rotate when turning the turtle, so they do not
display the heading of the turtle!</p>
</div>
</li>
<li><p class="first"><em>name</em> is an arbitrary string and <em>shape</em> is a tuple of pairs of
coordinates: Install the corresponding polygon shape.</p>
</li>
<li><p class="first"><em>name</em> is an arbitrary string and shape is a (compound) <a title="turtle.Shape" class="reference internal" href="#turtle.Shape"><tt class="xref docutils literal"><span class="pre">Shape</span></tt></a>
object: Install the corresponding compound shape.</p>
</li>
</ol>
<p>Add a turtle shape to TurtleScreen&#8217;s shapelist.  Only thusly registered
shapes can be used by issuing the command <tt class="docutils literal"><span class="pre">shape(shapename)</span></tt>.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">register_shape</span><span class="p">(</span><span class="s">&quot;turtle.gif&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">register_shape</span><span class="p">(</span><span class="s">&quot;triangle&quot;</span><span class="p">,</span> <span class="p">((</span><span class="mf">5</span><span class="p">,</span><span class="o">-</span><span class="mf">3</span><span class="p">),</span> <span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="mf">5</span><span class="p">),</span> <span class="p">(</span><span class="o">-</span><span class="mf">5</span><span class="p">,</span><span class="o">-</span><span class="mf">3</span><span class="p">)))</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.turtles">
<tt class="descclassname">turtle.</tt><tt class="descname">turtles</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.turtles" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the list of turtles on the screen.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">turtle</span> <span class="ow">in</span> <span class="n">screen</span><span class="o">.</span><span class="n">turtles</span><span class="p">()</span>
<span class="gp">... </span>    <span class="n">turtle</span><span class="o">.</span><span class="n">color</span><span class="p">(</span><span class="s">&quot;red&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<tt class="descclassname">turtle.</tt><tt class="descname">window_height</tt><big>(</big><big>)</big></dt>
<dd><p>Return the height of the turtle window.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">window_height</span><span class="p">()</span>
<span class="go">480</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt>
<tt class="descclassname">turtle.</tt><tt class="descname">window_width</tt><big>(</big><big>)</big></dt>
<dd><p>Return the width of the turtle window.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">window_width</span><span class="p">()</span>
<span class="go">640</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="methods-specific-to-screen-not-inherited-from-turtlescreen">
<span id="screenspecific"></span><h3>25.4.4.5. Methods specific to Screen, not inherited from TurtleScreen<a class="headerlink" href="#methods-specific-to-screen-not-inherited-from-turtlescreen" title="Permalink to this headline">¶</a></h3>
<dl class="function">
<dt id="turtle.bye">
<tt class="descclassname">turtle.</tt><tt class="descname">bye</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.bye" title="Permalink to this definition">¶</a></dt>
<dd>Shut the turtlegraphics window.</dd></dl>

<dl class="function">
<dt id="turtle.exitonclick">
<tt class="descclassname">turtle.</tt><tt class="descname">exitonclick</tt><big>(</big><big>)</big><a class="headerlink" href="#turtle.exitonclick" title="Permalink to this definition">¶</a></dt>
<dd><p>Bind bye() method to mouse clicks on the Screen.</p>
<p>If the value &#8220;using_IDLE&#8221; in the configuration dictionary is <tt class="xref docutils literal"><span class="pre">False</span></tt>
(default value), also enter mainloop.  Remark: If IDLE with the <tt class="docutils literal"><span class="pre">-n</span></tt> switch
(no subprocess) is used, this value should be set to <tt class="xref docutils literal"><span class="pre">True</span></tt> in
<tt class="docutils literal"><span class="pre">turtle.cfg</span></tt>.  In this case IDLE&#8217;s own mainloop is active also for the
client script.</p>
</dd></dl>

<dl class="function">
<dt id="turtle.setup">
<tt class="descclassname">turtle.</tt><tt class="descname">setup</tt><big>(</big><em>width=_CFG</em><span class="optional">[</span>, <em>&quot;width&quot;</em><span class="optional">]</span>, <em>height=_CFG</em><span class="optional">[</span>, <em>&quot;height&quot;</em><span class="optional">]</span>, <em>startx=_CFG</em><span class="optional">[</span>, <em>&quot;leftright&quot;</em><span class="optional">]</span>, <em>starty=_CFG</em><span class="optional">[</span>, <em>&quot;topbottom&quot;</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#turtle.setup" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the size and position of the main window.  Default values of arguments
are stored in the configuration dicionary and can be changed via a
<tt class="docutils literal"><span class="pre">turtle.cfg</span></tt> file.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>width</em> &#8211; if an integer, a size in pixels, if a float, a fraction of the
screen; default is 50% of screen</li>
<li><em>height</em> &#8211; if an integer, the height in pixels, if a float, a fraction of
the screen; default is 75% of screen</li>
<li><em>startx</em> &#8211; if positive, starting position in pixels from the left
edge of the screen, if negative from the right edge, if None,
center window horizontally</li>
<li><em>startx</em> &#8211; if positive, starting position in pixels from the top
edge of the screen, if negative from the bottom edge, if None,
center window vertically</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">setup</span> <span class="p">(</span><span class="n">width</span><span class="o">=</span><span class="mf">200</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="mf">200</span><span class="p">,</span> <span class="n">startx</span><span class="o">=</span><span class="mf">0</span><span class="p">,</span> <span class="n">starty</span><span class="o">=</span><span class="mf">0</span><span class="p">)</span>
<span class="go"># sets window to 200x200 pixels, in upper left of screen</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">setup</span><span class="p">(</span><span class="n">width</span><span class="o">=.</span><span class="mf">75</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="n">startx</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">starty</span><span class="o">=</span><span class="bp">None</span><span class="p">)</span>
<span class="go"># sets window to 75% of screen by 50% of screen and centers</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="turtle.title">
<tt class="descclassname">turtle.</tt><tt class="descname">title</tt><big>(</big><em>titlestring</em><big>)</big><a class="headerlink" href="#turtle.title" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>titlestring</em> &#8211; a string that is shown in the titlebar of the turtle
graphics window</td>
</tr>
</tbody>
</table>
<p>Set title of turtle window to <em>titlestring</em>.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">screen</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="s">&quot;Welcome to the turtle zoo!&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>
<div class="section" id="the-public-classes-of-the-module-turtle">
<h2>25.4.5. The public classes of the module <tt class="xref docutils literal"><span class="pre">turtle</span></tt><a class="headerlink" href="#the-public-classes-of-the-module-turtle" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="turtle.RawTurtle">
<em class="property">
class </em><tt class="descclassname">turtle.</tt><tt class="descname">RawTurtle</tt><big>(</big><em>canvas</em><big>)</big><a class="headerlink" href="#turtle.RawTurtle" title="Permalink to this definition">¶</a></dt>
<dt id="turtle.RawPen">
<em class="property">
class </em><tt class="descclassname">turtle.</tt><tt class="descname">RawPen</tt><big>(</big><em>canvas</em><big>)</big><a class="headerlink" href="#turtle.RawPen" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>canvas</em> &#8211; <dl class="docutils">
<dt>a <tt class="xref docutils literal"><span class="pre">Tkinter.Canvas</span></tt>, a <tt class="xref docutils literal"><span class="pre">ScrolledCanvas</span></tt> or a</dt>
<dd><a title="turtle.TurtleScreen" class="reference internal" href="#turtle.TurtleScreen"><tt class="xref docutils literal"><span class="pre">TurtleScreen</span></tt></a></dd>
</dl>
<p>Create a turtle.  The turtle has all methods described above as &#8220;methods of
Turtle/RawTurtle&#8221;.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="turtle.Turtle">
<em class="property">
class </em><tt class="descclassname">turtle.</tt><tt class="descname">Turtle</tt><a class="headerlink" href="#turtle.Turtle" title="Permalink to this definition">¶</a></dt>
<dd>Subclass of RawTurtle, has the same interface but draws on a default
<a title="turtle.Screen" class="reference internal" href="#turtle.Screen"><tt class="xref docutils literal"><span class="pre">Screen</span></tt></a> object created automatically when needed for the first time.</dd></dl>

<dl class="class">
<dt id="turtle.TurtleScreen">
<em class="property">
class </em><tt class="descclassname">turtle.</tt><tt class="descname">TurtleScreen</tt><big>(</big><em>cv</em><big>)</big><a class="headerlink" href="#turtle.TurtleScreen" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>cv</em> &#8211; a <tt class="xref docutils literal"><span class="pre">Tkinter.Canvas</span></tt></td>
</tr>
</tbody>
</table>
<p>Provides screen oriented methods like <tt class="xref docutils literal"><span class="pre">setbg()</span></tt> etc. that are described
above.</p>
</dd></dl>

<dl class="class">
<dt id="turtle.Screen">
<em class="property">
class </em><tt class="descclassname">turtle.</tt><tt class="descname">Screen</tt><a class="headerlink" href="#turtle.Screen" title="Permalink to this definition">¶</a></dt>
<dd>Subclass of TurtleScreen, with <a class="reference internal" href="#screenspecific"><em>four methods added</em></a>.</dd></dl>

<dl class="class">
<dt id="turtle.ScrolledCavas">
<em class="property">
class </em><tt class="descclassname">turtle.</tt><tt class="descname">ScrolledCavas</tt><big>(</big><em>master</em><big>)</big><a class="headerlink" href="#turtle.ScrolledCavas" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>master</em> &#8211; some Tkinter widget to contain the ScrolledCanvas, i.e.
a Tkinter-canvas with scrollbars added</td>
</tr>
</tbody>
</table>
<p>Used by class Screen, which thus automatically provides a ScrolledCanvas as
playground for the turtles.</p>
</dd></dl>

<dl class="class">
<dt id="turtle.Shape">
<em class="property">
class </em><tt class="descclassname">turtle.</tt><tt class="descname">Shape</tt><big>(</big><em>type_</em>, <em>data</em><big>)</big><a class="headerlink" href="#turtle.Shape" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>type_</em> &#8211; one of the strings &#8220;polygon&#8221;, &#8220;image&#8221;, &#8220;compound&#8221;</td>
</tr>
</tbody>
</table>
<p>Data structure modeling shapes.  The pair <tt class="docutils literal"><span class="pre">(type_,</span> <span class="pre">data)</span></tt> must follow this
specification:</p>
<table border="1" class="docutils">
<colgroup>
<col width="16%" />
<col width="84%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head"><em>type_</em></th>
<th class="head"><em>data</em></th>
</tr>
</thead>
<tbody valign="top">
<tr><td>&#8220;polygon&#8221;</td>
<td>a polygon-tuple, i.e. a tuple of pairs of coordinates</td>
</tr>
<tr><td>&#8220;image&#8221;</td>
<td>an image  (in this form only used internally!)</td>
</tr>
<tr><td>&#8220;compound&#8221;</td>
<td><tt class="xref docutils literal"><span class="pre">None</span></tt> (a compound shape has to be constructed using the
<a title="turtle.Shape.addcomponent" class="reference internal" href="#turtle.Shape.addcomponent"><tt class="xref docutils literal"><span class="pre">addcomponent()</span></tt></a> method)</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="turtle.Shape.addcomponent">
<tt class="descname">addcomponent</tt><big>(</big><em>poly</em>, <em>fill</em>, <em>outline=None</em><big>)</big><a class="headerlink" href="#turtle.Shape.addcomponent" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><em>poly</em> &#8211; a polygon, i.e. a tuple of pairs of numbers</li>
<li><em>fill</em> &#8211; a color the <em>poly</em> will be filled with</li>
<li><em>outline</em> &#8211; a color for the poly&#8217;s outline (if given)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">poly</span> <span class="o">=</span> <span class="p">((</span><span class="mf">0</span><span class="p">,</span><span class="mf">0</span><span class="p">),(</span><span class="mf">10</span><span class="p">,</span><span class="o">-</span><span class="mf">5</span><span class="p">),(</span><span class="mf">0</span><span class="p">,</span><span class="mf">10</span><span class="p">),(</span><span class="o">-</span><span class="mf">10</span><span class="p">,</span><span class="o">-</span><span class="mf">5</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span> <span class="o">=</span> <span class="n">Shape</span><span class="p">(</span><span class="s">&quot;compound&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">s</span><span class="o">.</span><span class="n">addcomponent</span><span class="p">(</span><span class="n">poly</span><span class="p">,</span> <span class="s">&quot;red&quot;</span><span class="p">,</span> <span class="s">&quot;blue&quot;</span><span class="p">)</span>
<span class="go"># .. add more components and then use register_shape()</span>
</pre></div>
</div>
<p>See <a class="reference internal" href="#compoundshapes"><em>Excursus about the use of compound shapes</em></a>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="turtle.Vec2D">
<em class="property">
class </em><tt class="descclassname">turtle.</tt><tt class="descname">Vec2D</tt><big>(</big><em>x</em>, <em>y</em><big>)</big><a class="headerlink" href="#turtle.Vec2D" title="Permalink to this definition">¶</a></dt>
<dd><p>A two-dimensional vector class, used as a helper class for implementing
turtle graphics.  May be useful for turtle graphics programs too.  Derived
from tuple, so a vector is a tuple!</p>
<p>Provides (for <em>a</em>, <em>b</em> vectors, <em>k</em> number):</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">a</span> <span class="pre">+</span> <span class="pre">b</span></tt> vector addition</li>
<li><tt class="docutils literal"><span class="pre">a</span> <span class="pre">-</span> <span class="pre">b</span></tt> vector subtraction</li>
<li><tt class="docutils literal"><span class="pre">a</span> <span class="pre">*</span> <span class="pre">b</span></tt> inner product</li>
<li><tt class="docutils literal"><span class="pre">k</span> <span class="pre">*</span> <span class="pre">a</span></tt> and <tt class="docutils literal"><span class="pre">a</span> <span class="pre">*</span> <span class="pre">k</span></tt> multiplication with scalar</li>
<li><tt class="docutils literal"><span class="pre">abs(a)</span></tt> absolute value of a</li>
<li><tt class="docutils literal"><span class="pre">a.rotate(angle)</span></tt> rotation</li>
</ul>
</dd></dl>

</div>
<div class="section" id="help-and-configuration">
<h2>25.4.6. Help and configuration<a class="headerlink" href="#help-and-configuration" title="Permalink to this headline">¶</a></h2>
<div class="section" id="how-to-use-help">
<h3>25.4.6.1. How to use help<a class="headerlink" href="#how-to-use-help" title="Permalink to this headline">¶</a></h3>
<p>The public methods of the Screen and Turtle classes are documented extensively
via docstrings.  So these can be used as online-help via the Python help
facilities:</p>
<ul>
<li><p class="first">When using IDLE, tooltips show the signatures and first lines of the
docstrings of typed in function-/method calls.</p>
</li>
<li><p class="first">Calling <a title="help" class="reference external" href="functions.html#help"><tt class="xref docutils literal"><span class="pre">help()</span></tt></a> on methods or functions displays the docstrings:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">Screen</span><span class="o">.</span><span class="n">bgcolor</span><span class="p">)</span>
<span class="go">Help on method bgcolor in module turtle:</span>

<span class="go">bgcolor(self, *args) unbound turtle.Screen method</span>
<span class="go">    Set or return backgroundcolor of the TurtleScreen.</span>

<span class="go">    Arguments (if given): a color string or three numbers</span>
<span class="go">    in the range 0..colormode or a 3-tuple of such numbers.</span>


<span class="go">      &gt;&gt;&gt; screen.bgcolor(&quot;orange&quot;)</span>
<span class="go">      &gt;&gt;&gt; screen.bgcolor()</span>
<span class="go">      &quot;orange&quot;</span>
<span class="go">      &gt;&gt;&gt; screen.bgcolor(0.5,0,0.5)</span>
<span class="go">      &gt;&gt;&gt; screen.bgcolor()</span>
<span class="go">      &quot;#800080&quot;</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">Turtle</span><span class="o">.</span><span class="n">penup</span><span class="p">)</span>
<span class="go">Help on method penup in module turtle:</span>

<span class="go">penup(self) unbound turtle.Turtle method</span>
<span class="go">    Pull the pen up -- no drawing when moving.</span>

<span class="go">    Aliases: penup | pu | up</span>

<span class="go">    No argument</span>

<span class="go">    &gt;&gt;&gt; turtle.penup()</span>
</pre></div>
</div>
</li>
<li><p class="first">The docstrings of the functions which are derived from methods have a modified
form:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">bgcolor</span><span class="p">)</span>
<span class="go">Help on function bgcolor in module turtle:</span>

<span class="go">bgcolor(*args)</span>
<span class="go">    Set or return backgroundcolor of the TurtleScreen.</span>

<span class="go">    Arguments (if given): a color string or three numbers</span>
<span class="go">    in the range 0..colormode or a 3-tuple of such numbers.</span>

<span class="go">    Example::</span>

<span class="go">      &gt;&gt;&gt; bgcolor(&quot;orange&quot;)</span>
<span class="go">      &gt;&gt;&gt; bgcolor()</span>
<span class="go">      &quot;orange&quot;</span>
<span class="go">      &gt;&gt;&gt; bgcolor(0.5,0,0.5)</span>
<span class="go">      &gt;&gt;&gt; bgcolor()</span>
<span class="go">      &quot;#800080&quot;</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">penup</span><span class="p">)</span>
<span class="go">Help on function penup in module turtle:</span>

<span class="go">penup()</span>
<span class="go">    Pull the pen up -- no drawing when moving.</span>

<span class="go">    Aliases: penup | pu | up</span>

<span class="go">    No argument</span>

<span class="go">    Example:</span>
<span class="go">    &gt;&gt;&gt; penup()</span>
</pre></div>
</div>
</li>
</ul>
<p>These modified docstrings are created automatically together with the function
definitions that are derived from the methods at import time.</p>
</div>
<div class="section" id="translation-of-docstrings-into-different-languages">
<h3>25.4.6.2. Translation of docstrings into different languages<a class="headerlink" href="#translation-of-docstrings-into-different-languages" title="Permalink to this headline">¶</a></h3>
<p>There is a utility to create a dictionary the keys of which are the method names
and the values of which are the docstrings of the public methods of the classes
Screen and Turtle.</p>
<dl class="function">
<dt id="turtle.write_docstringdict">
<tt class="descclassname">turtle.</tt><tt class="descname">write_docstringdict</tt><big>(</big><em>filename=&quot;turtle_docstringdict&quot;</em><big>)</big><a class="headerlink" href="#turtle.write_docstringdict" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>filename</em> &#8211; a string, used as filename</td>
</tr>
</tbody>
</table>
<p>Create and write docstring-dictionary to a Python script with the given
filename.  This function has to be called explicitly (it is not used by the
turtle graphics classes).  The docstring dictionary will be written to the
Python script <tt class="docutils literal"><em><span class="pre">filename</span></em><span class="pre">.py</span></tt>.  It is intended to serve as a template
for translation of the docstrings into different languages.</p>
</dd></dl>

<p>If you (or your students) want to use <tt class="xref docutils literal"><span class="pre">turtle</span></tt> with online help in your
native language, you have to translate the docstrings and save the resulting
file as e.g. <tt class="docutils literal"><span class="pre">turtle_docstringdict_german.py</span></tt>.</p>
<p>If you have an appropriate entry in your <tt class="docutils literal"><span class="pre">turtle.cfg</span></tt> file this dictionary
will be read in at import time and will replace the original English docstrings.</p>
<p>At the time of this writing there are docstring dictionaries in German and in
Italian.  (Requests please to <a class="reference external" href="mailto:glingl&#37;&#52;&#48;aon&#46;at">glingl<span>&#64;</span>aon<span>&#46;</span>at</a>.)</p>
</div>
<div class="section" id="how-to-configure-screen-and-turtles">
<h3>25.4.6.3. How to configure Screen and Turtles<a class="headerlink" href="#how-to-configure-screen-and-turtles" title="Permalink to this headline">¶</a></h3>
<p>The built-in default configuration mimics the appearance and behaviour of the
old turtle module in order to retain best possible compatibility with it.</p>
<p>If you want to use a different configuration which better reflects the features
of this module or which better fits to your needs, e.g. for use in a classroom,
you can prepare a configuration file <tt class="docutils literal"><span class="pre">turtle.cfg</span></tt> which will be read at import
time and modify the configuration according to its settings.</p>
<p>The built in configuration would correspond to the following turtle.cfg:</p>
<div class="highlight-python"><pre>width = 0.5
height = 0.75
leftright = None
topbottom = None
canvwidth = 400
canvheight = 300
mode = standard
colormode = 1.0
delay = 10
undobuffersize = 1000
shape = classic
pencolor = black
fillcolor = black
resizemode = noresize
visible = True
language = english
exampleturtle = turtle
examplescreen = screen
title = Python Turtle Graphics
using_IDLE = False</pre>
</div>
<p>Short explanation of selected entries:</p>
<ul class="simple">
<li>The first four lines correspond to the arguments of the <tt class="xref docutils literal"><span class="pre">Screen.setup()</span></tt>
method.</li>
<li>Line 5 and 6 correspond to the arguments of the method
<tt class="xref docutils literal"><span class="pre">Screen.screensize()</span></tt>.</li>
<li><em>shape</em> can be any of the built-in shapes, e.g: arrow, turtle, etc.  For more
info try <tt class="docutils literal"><span class="pre">help(shape)</span></tt>.</li>
<li>If you want to use no fillcolor (i.e. make the turtle transparent), you have
to write <tt class="docutils literal"><span class="pre">fillcolor</span> <span class="pre">=</span> <span class="pre">&quot;&quot;</span></tt> (but all nonempty strings must not have quotes in
the cfg-file).</li>
<li>If you want to reflect the turtle its state, you have to use <tt class="docutils literal"><span class="pre">resizemode</span> <span class="pre">=</span>
<span class="pre">auto</span></tt>.</li>
<li>If you set e.g. <tt class="docutils literal"><span class="pre">language</span> <span class="pre">=</span> <span class="pre">italian</span></tt> the docstringdict
<tt class="docutils literal"><span class="pre">turtle_docstringdict_italian.py</span></tt> will be loaded at import time (if
present on the import path, e.g. in the same directory as <tt class="xref docutils literal"><span class="pre">turtle</span></tt>.</li>
<li>The entries <em>exampleturtle</em> and <em>examplescreen</em> define the names of these
objects as they occur in the docstrings.  The transformation of
method-docstrings to function-docstrings will delete these names from the
docstrings.</li>
<li><em>using_IDLE</em>: Set this to <tt class="xref docutils literal"><span class="pre">True</span></tt> if you regularly work with IDLE and its -n
switch (&#8220;no subprocess&#8221;).  This will prevent <a title="turtle.exitonclick" class="reference internal" href="#turtle.exitonclick"><tt class="xref docutils literal"><span class="pre">exitonclick()</span></tt></a> to enter the
mainloop.</li>
</ul>
<p>There can be a <tt class="docutils literal"><span class="pre">turtle.cfg</span></tt> file in the directory where <tt class="xref docutils literal"><span class="pre">turtle</span></tt> is
stored and an additional one in the current working directory.  The latter will
override the settings of the first one.</p>
<p>The <tt class="docutils literal"><span class="pre">Demo/turtle</span></tt> directory contains a <tt class="docutils literal"><span class="pre">turtle.cfg</span></tt> file.  You can
study it as an example and see its effects when running the demos (preferably
not from within the demo-viewer).</p>
</div>
</div>
<div class="section" id="demo-scripts">
<h2>25.4.7. Demo scripts<a class="headerlink" href="#demo-scripts" title="Permalink to this headline">¶</a></h2>
<p>There is a set of demo scripts in the turtledemo directory located in the
<tt class="docutils literal"><span class="pre">Demo/turtle</span></tt> directory in the source distribution.</p>
<p>It contains:</p>
<ul class="simple">
<li>a set of 15 demo scripts demonstrating different features of the new module
<tt class="xref docutils literal"><span class="pre">turtle</span></tt></li>
<li>a demo viewer <tt class="docutils literal"><span class="pre">turtleDemo.py</span></tt> which can be used to view the sourcecode
of the scripts and run them at the same time. 14 of the examples can be
accessed via the Examples menu; all of them can also be run standalone.</li>
<li>The example <tt class="docutils literal"><span class="pre">turtledemo_two_canvases.py</span></tt> demonstrates the simultaneous
use of two canvases with the turtle module.  Therefore it only can be run
standalone.</li>
<li>There is a <tt class="docutils literal"><span class="pre">turtle.cfg</span></tt> file in this directory, which also serves as an
example for how to write and use such files.</li>
</ul>
<p>The demoscripts are:</p>
<table border="1" class="docutils">
<colgroup>
<col width="23%" />
<col width="43%" />
<col width="33%" />
</colgroup>
<tbody valign="top">
<tr><td>Name</td>
<td>Description</td>
<td>Features</td>
</tr>
<tr><td>bytedesign</td>
<td>complex classical
turtlegraphics pattern</td>
<td><a title="turtle.tracer" class="reference internal" href="#turtle.tracer"><tt class="xref docutils literal"><span class="pre">tracer()</span></tt></a>, delay,
<a title="turtle.update" class="reference internal" href="#turtle.update"><tt class="xref docutils literal"><span class="pre">update()</span></tt></a></td>
</tr>
<tr><td>chaos</td>
<td>graphs verhust dynamics,
proves that you must not
trust computers&#8217; computations</td>
<td>world coordinates</td>
</tr>
<tr><td>clock</td>
<td>analog clock showing time
of your computer</td>
<td>turtles as clock&#8217;s
hands, ontimer</td>
</tr>
<tr><td>colormixer</td>
<td>experiment with r, g, b</td>
<td><a title="turtle.ondrag" class="reference internal" href="#turtle.ondrag"><tt class="xref docutils literal"><span class="pre">ondrag()</span></tt></a></td>
</tr>
<tr><td>fractalcurves</td>
<td>Hilbert &amp; Koch curves</td>
<td>recursion</td>
</tr>
<tr><td>lindenmayer</td>
<td>ethnomathematics
(indian kolams)</td>
<td>L-System</td>
</tr>
<tr><td>minimal_hanoi</td>
<td>Towers of Hanoi</td>
<td>Rectangular Turtles
as Hanoi discs
(shape, shapesize)</td>
</tr>
<tr><td>paint</td>
<td>super minimalistic
drawing program</td>
<td><a title="turtle.onclick" class="reference internal" href="#turtle.onclick"><tt class="xref docutils literal"><span class="pre">onclick()</span></tt></a></td>
</tr>
<tr><td>peace</td>
<td>elementary</td>
<td>turtle: appearance
and animation</td>
</tr>
<tr><td>penrose</td>
<td>aperiodic tiling with
kites and darts</td>
<td><a title="turtle.stamp" class="reference internal" href="#turtle.stamp"><tt class="xref docutils literal"><span class="pre">stamp()</span></tt></a></td>
</tr>
<tr><td>planet_and_moon</td>
<td>simulation of
gravitational system</td>
<td>compound shapes,
<a title="turtle.Vec2D" class="reference internal" href="#turtle.Vec2D"><tt class="xref docutils literal"><span class="pre">Vec2D</span></tt></a></td>
</tr>
<tr><td>tree</td>
<td>a (graphical) breadth
first tree (using generators)</td>
<td><a title="turtle.clone" class="reference internal" href="#turtle.clone"><tt class="xref docutils literal"><span class="pre">clone()</span></tt></a></td>
</tr>
<tr><td>wikipedia</td>
<td>a pattern from the wikipedia
article on turtle graphics</td>
<td><a title="turtle.clone" class="reference internal" href="#turtle.clone"><tt class="xref docutils literal"><span class="pre">clone()</span></tt></a>,
<a title="turtle.undo" class="reference internal" href="#turtle.undo"><tt class="xref docutils literal"><span class="pre">undo()</span></tt></a></td>
</tr>
<tr><td>yingyang</td>
<td>another elementary example</td>
<td><a title="turtle.circle" class="reference internal" href="#turtle.circle"><tt class="xref docutils literal"><span class="pre">circle()</span></tt></a></td>
</tr>
</tbody>
</table>
<p>Have fun!</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="../contents.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href="">25.4. <tt class="docutils literal"><span class="pre">turtle</span></tt> &#8212; Turtle graphics for Tk</a><ul>
<li><a class="reference external" href="#introduction">25.4.1. Introduction</a></li>
<li><a class="reference external" href="#overview-over-available-turtle-and-screen-methods">25.4.2. Overview over available Turtle and Screen methods</a><ul>
<li><a class="reference external" href="#turtle-methods">25.4.2.1. Turtle methods</a></li>
<li><a class="reference external" href="#methods-of-turtlescreen-screen">25.4.2.2. Methods of TurtleScreen/Screen</a></li>
</ul>
</li>
<li><a class="reference external" href="#methods-of-rawturtle-turtle-and-corresponding-functions">25.4.3. Methods of RawTurtle/Turtle and corresponding functions</a><ul>
<li><a class="reference external" href="#turtle-motion">25.4.3.1. Turtle motion</a></li>
<li><a class="reference external" href="#tell-turtle-s-state">25.4.3.2. Tell Turtle&#8217;s state</a></li>
<li><a class="reference external" href="#settings-for-measurement">25.4.3.3. Settings for measurement</a></li>
<li><a class="reference external" href="#pen-control">25.4.3.4. Pen control</a><ul>
<li><a class="reference external" href="#drawing-state">25.4.3.4.1. Drawing state</a></li>
<li><a class="reference external" href="#color-control">25.4.3.4.2. Color control</a></li>
<li><a class="reference external" href="#filling">25.4.3.4.3. Filling</a></li>
<li><a class="reference external" href="#more-drawing-control">25.4.3.4.4. More drawing control</a></li>
</ul>
</li>
<li><a class="reference external" href="#turtle-state">25.4.3.5. Turtle state</a><ul>
<li><a class="reference external" href="#visibility">25.4.3.5.1. Visibility</a></li>
<li><a class="reference external" href="#appearance">25.4.3.5.2. Appearance</a></li>
</ul>
</li>
<li><a class="reference external" href="#using-events">25.4.3.6. Using events</a></li>
<li><a class="reference external" href="#special-turtle-methods">25.4.3.7. Special Turtle methods</a></li>
<li><a class="reference external" href="#excursus-about-the-use-of-compound-shapes">25.4.3.8. Excursus about the use of compound shapes</a></li>
</ul>
</li>
<li><a class="reference external" href="#methods-of-turtlescreen-screen-and-corresponding-functions">25.4.4. Methods of TurtleScreen/Screen and corresponding functions</a><ul>
<li><a class="reference external" href="#window-control">25.4.4.1. Window control</a></li>
<li><a class="reference external" href="#animation-control">25.4.4.2. Animation control</a></li>
<li><a class="reference external" href="#using-screen-events">25.4.4.3. Using screen events</a></li>
<li><a class="reference external" href="#settings-and-special-methods">25.4.4.4. Settings and special methods</a></li>
<li><a class="reference external" href="#methods-specific-to-screen-not-inherited-from-turtlescreen">25.4.4.5. Methods specific to Screen, not inherited from TurtleScreen</a></li>
</ul>
</li>
<li><a class="reference external" href="#the-public-classes-of-the-module-turtle">25.4.5. The public classes of the module <tt class="docutils literal"><span class="pre">turtle</span></tt></a></li>
<li><a class="reference external" href="#help-and-configuration">25.4.6. Help and configuration</a><ul>
<li><a class="reference external" href="#how-to-use-help">25.4.6.1. How to use help</a></li>
<li><a class="reference external" href="#translation-of-docstrings-into-different-languages">25.4.6.2. Translation of docstrings into different languages</a></li>
<li><a class="reference external" href="#how-to-configure-screen-and-turtles">25.4.6.3. How to configure Screen and Turtles</a></li>
</ul>
</li>
<li><a class="reference external" href="#demo-scripts">25.4.7. Demo scripts</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="scrolledtext.html"
                                  title="previous chapter">25.3. <tt class="docutils literal docutils literal docutils literal"><span class="pre">ScrolledText</span></tt> &#8212; Scrolled Text Widget</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="idle.html"
                                  title="next chapter">25.5. IDLE</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/library/turtle.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="../search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="idle.html" title="25.5. IDLE"
             >next</a> |</li>
        <li class="right" >
          <a href="scrolledtext.html" title="25.3. ScrolledText — Scrolled Text Widget"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v2.6.2 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="tk.html" >25. Graphical User Interfaces with Tk</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; <a href="../copyright.html">Copyright</a> 1990-2009, Python Software Foundation.
      Last updated on Apr 15, 2009.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.1.
    </div>
  </body>
</html>